(()=>{var __webpack_modules__={884:(e,t,o)=>{const n=o(839),i=(o(570),o(1)),r=o(721);let s=e.exports={addCartAddSubmitClickListener:function(e,t){let o=e.querySelectorAll("button,input");if(o)for(let e=0;e"product-addons"===e.upsellType)))if(e||o.addToCartBtnSelector){let i=e&&o.addToCartBtnSelector?`${e}, ${o.addToCartBtnSelector}`:e||o.addToCartBtnSelector;n.log("custom Selectors",i);let r=t.version>=18?document.querySelectorAll(i):[document.querySelector(e),document.querySelector(o.addToCartBtnSelector)];r&&(n.log("Replaced submitButtons with custom addToCartBtnSelectors:",r),s.addListenersToElements(r,t.version>=18?"lb-upsell-custom-ATC-listener":"listener"))}else{let e=r.getProductCartAddForms();e&&e.length&&(s.addCartAddSubmitClickListener(e[0],s.handleAddToCart),n.upsellFunnelLog("Registered add to cart form listeners"))}else n.upsellFunnelLog("product-addons not setup, so not registering listeners")},handleAddToCart:function(e,t){if(n.isAddToCartClickForced)n.log("Add to cart click is forced"),n.isAddToCartClickForcedReset&&(n.isAddToCartClickForced=!1);else{e.preventDefault?e.preventDefault():e.returnValue=!1,e.stopImmediatePropagation&&e.stopImmediatePropagation(),n.isAddToCartClickForcedReset=!1;let o=t||e.srcElement;i.ppaWidgetLib().handleAddToCart(o),n.log("------------")}}}},44:(e,t,o)=>{const n=o(839),i=o(570),r=(o(873),o(721));let s,d=e.exports={getCartItems:function(){return s},isThankyouPage:function(){return-1!==window.location.pathname.indexOf("/orders/")||-1!==window.location.pathname.indexOf("/thank_you")&&-1!==window.location.pathname.indexOf("/checkouts/")},proceedToCheckout:function(e,t,o,r,s,d,l){n.upsellFunnelLog("Proceeding to cart"),t&&n.isDiscountStacked()&&window.lbUpsellComponents&&void 0===window.lbUpsellComponents.handleUpsellFunnelCheckout&&(n.log("Defining handleUpsellFunnelCheckout for stack discounts"),window.lbUpsellComponents.handleUpsellFunnelCheckout=function(e){return new Promise(((t,o)=>{n.log("handleUpsellFunnelCheckout called",e),setTimeout((()=>{t("proceed")}),2e3)}))});let a,c=n.getSetup(),u=n.getWidgetSetup(c,"popup-upsell-funnel-widget"),p=n.getWidgetSetup(c,"popup-cart-addons-widget"),g=!1;if(window.lbUpsellComponents&&window.lbUpsellComponents.isAnchorTagUsedForCheckout||o&&o.tagName&&"a"===o.tagName.toLowerCase()&&"/checkout"===o.getAttribute("href")){n.upsellFunnelLog("Anchor tag checkout is used"),g=!0;let e=i.getDiscountFromStorage();d&&e&&!t&&(t=e,n.upsellFunnelLog("Replacing anchor tag discount code",t))}window.lbUpsellComponents&&window.lbUpsellComponents.handleUpsellFunnelCheckout?(n.log("handleUpsellFunnelCheckout will be called"),a=window.lbUpsellComponents.handleUpsellFunnelCheckout({acceptedProducts:e,discount:t,isPPCSEOrPPADiscValid:d})):(n.log("proceeding to checkout without checkoutPromise"),a=Promise.resolve()),a.then((async i=>{if(n.log("result",i),r)n.upsellFunnelLog("Rendered by external app, triggering custom event"),n.triggerCustomEvent({acceptedProducts:e,discount:t},"selleasy-checkout-popup-completed");else if(("popup-upsell-funnel-widget"===s&&u&&u.isWindowRedirectUsedForCheckout||"popup-cart-addons-widget"===s&&p&&p.isWindowRedirectUsedForCheckout)&&e&&e.length&&l&&l.items&&e.some((e=>l.items.some((t=>`${t.product_id}`==`${e.id}`))))||g){n.upsellFunnelLog("Using window redirection for 1+1 offers");let e=n.getRootRoute();window.location.href=e&&"/"!==e?`${e}cart/checkout${t?`?discount=${t.code}`:""}`:"/cart/checkout"+(t?`?discount=${t.code}`:"")}else n.isCheckoutClickForced=!0,o.disabled=!1,o&&t&&t.code&&window&&window.location?(c&&c.isDealeasyIntegrated&&window.lbDealeasy&&"function"==typeof window.lbDealeasy.applyDiscountsToCart&&await window.lbDealeasy.applyDiscountsToCart([t.code],"selleasy"),o.click()):o.click();setTimeout((()=>{const e=document.querySelector("#lb-upsell-modal-bg-id");e&&(e.style.display="none");const t=document.querySelector(".lb-upsell-modal-container");t&&(t.style.display="none");const o=document.querySelector("#lb-addon-popup-bg-id");o&&(o.style.display="block");const n=document.querySelector("#lb-addon-popup-container-id");n&&(n.style.display="block"),document.body.classList.remove("lb-upsell-prevent-scroll")}),5e3)}))},getFormattedWidgetInput:function(e,t,o,i,d){return new Promise(((l,a)=>{const c=n.getSetup();let u={boughtTogether:[],discounts:"popup-cart-addons"===t.upsellType&&o?t.discounts:t.tpaeDiscounts,overrideWidgeTitle:t.overrideWidgeTitle},p={styles:e.styles,content:e.content,isQuantityPickerEnabled:e.isQuantityPickerEnabled||!0,imageResolution:e.imageResolution,isMultipleVariantsAdded:"tq-page-addon-embedded-widget"===e.type?!1!==e.isMultipleVariantsAdded:e.isMultipleVariantsAdded,isQtyPickerHidden:e.isQtyPickerHidden,metadata:{shopCurrencyFormat:c&&c.shopEmailCurrencyFormat?c.shopEmailCurrencyFormat:c.shopCurrencyFormat,isAmountNoDecimals:c&&c.isAmountNoDecimals,shopMoneyInEmailsFormat:c&&c.shopMoneyInEmailsFormat,shopCurrencyCode:c&&c.shopCurrencyCode,presentmentCurrency:void 0,isUnitPriceShown:c&&c.isUnitPriceShown,setupVersion:c.version,variantsGroupSeperator:c.variantsGroupSeperator}},g=n.getTranslations(c,e,t,u,p);u=g.offer,p=g.widget;let f=[];if(t.boughtTogether.offeredProducts.products&&t.boughtTogether.offeredProducts.products.length&&t.boughtTogether.offeredProducts.products.forEach((e=>{f.push(e.handle)})),"popup-cart-addons"===t.upsellType&&u.discounts&&Number(u.discounts.minimumCartAmount)>0){const e=n.getPresentmentCurrency();let t=100*Number(u.discounts.minimumCartAmount)*Number(e&&e.rate||1);t>i.total_price&&(n.ppaLog(`Discounts will not be shown due to minimumCartAmount cond. minimumCartAmount - ${t}, cart total - ${i.total_price}`),u.discounts=void 0)}let m=[];t.boughtTogether.shopifyProductRecommendations&&t.boughtTogether.shopifyProductRecommendations.isEnabled?m.push(r.getShopifyProductRecomendation(d.id,t.boughtTogether.shopifyProductRecommendations.limit)):m.push(n.getProducts(f)),Promise.all(m).then((o=>{let i;n.ppaLog("--------Processing best offer --------"),t.boughtTogether.shopifyProductRecommendations&&t.boughtTogether.shopifyProductRecommendations.isEnabled?(i=o&&o[0].products&&o[0].products.length?[d,...o[0].products]:[d],u.discounts={...t.discounts,discountType:"byProducts"},i.forEach((e=>{e.productId=e.id,t.discounts&&t.discounts.isEnabled&&t.discounts.value>0&&(e.discount={type:t.discounts.type,value:t.discounts.value})}))):i=o&&o[0].length?o[0]:[];let r=n.filterProducts(i,e);n.ppaLog("Filtered Products based on product/variant availablity & image:",r);let a=t.boughtTogether.shopifyProductRecommendations&&t.boughtTogether.shopifyProductRecommendations.isEnabled?JSON.parse(JSON.stringify(o[0].products)):JSON.parse(JSON.stringify(t.boughtTogether.offeredProducts.products));a=n.getBoughtProductsRandomSortOrder(a,t.isSortedRandomly),a.sort(((e,t)=>e.sortNo-t.sortNo));let c=t.boughtTogether.shopifyProductRecommendations&&t.boughtTogether.shopifyProductRecommendations.isEnabled?t.discounts&&t.discounts.isEnabled&&t.discounts.value>0:t.tpaeDiscounts&&t.tpaeDiscounts.isEnabled&&"byProducts"===t.tpaeDiscounts.discountType&&e.type;a=n.mapAvailableProducts(a,r,t.for.selectorType,void 0,c,s),a=n.removeExtraItems(a,e.maxItemsInOffer),u.boughtTogether=a,p.metadata.presentmentCurrency=n.getPresentmentCurrency(),p.addToCartAction=e.addToCartAction,p.layoutStyle=e.layoutStyle||"singleProductSlider",p.addActionStyle=e.addActionStyle||"button",p.productClickActionStyle=e.productClickActionStyle||"popup",l({widget:p,offer:{for:t.for,boughtTogether:u.boughtTogether,overrideWidgeTitle:u.overrideWidgeTitle,discounts:u.discounts}})})).catch((e=>{n.ppaLog("Error while getProducts",e),a(e)}))}))},getApplicableOffer:function(e,t,o){return new Promise(((i,r)=>{let d=e.offers&&e.offers.length?JSON.parse(JSON.stringify(e.offers.filter((e=>o.some((t=>t===e.upsellType)))))):[],l=[];if(d&&d.length&&t&&t.items){let e=[],a=[];t.items.forEach((t=>{a.push({productId:t.product_id,variantId:t.variant_id}),e.push(t.handle)})),(o.includes("tq-page-upsell")?Promise.resolve(t.items):n.getProducts(e)).then((e=>{s=e&&JSON.parse(JSON.stringify(e)),e.forEach((t=>{let o=d.filter((o=>{let n=o.for.triggerConditions||[];return!(n.length>0&&n.some((t=>"productExclusion"===t.type&&t.products&&t.products.length&&t.products.some((t=>e.some((e=>t.productId===`${e.id}`)))))))&&(!l.some((e=>e.recordType===o.recordType))&&("products"===o.for.selectorType?o.for.products.some((e=>o.for.isVariantsSelection&&e.limitVariants?e.productId===`${t.id}`&&e.limitVariants.some((e=>e.id===`${a.filter((e=>e.productId===t.id))[0].variantId}`)):e.productId===`${t.id}`)):"tags"===o.for.selectorType&&t.tags&&t.tags.length?o.for.products.some((e=>t.tags.some((t=>(t||"").toLowerCase()===(e.name||"").toLowerCase())))):"all"===o.for.selectorType||void 0))}));o.length&&l.push(...o)})),n.upsellFunnelLog("applicableOffers:",l),l.length?i(n.sortByPriorityAndLatestOffer(l)[0]):i(void 0)})).catch((e=>{console.log("Err while getApplicableOffer:",e),r("Error while fetching products",e)}))}else i(void 0)}))},getOrderQueryResponse:function(e,t=void 0){return new Promise(((o,i)=>{let r=`${n.getHostName()}/order`+(t?`/${t}`:""),s=new XMLHttpRequest;s.open("POST",r,!0),s.setRequestHeader("Content-Type","application/json; charset=UTF-8"),s.setRequestHeader("Access-Control-Allow-Origin","*"),s.send(JSON.stringify(e)),s.onload=()=>{n.log("tqOrderReq.responseText",s.responseText),200===s.status?o(JSON.parse(s.responseText)):i(`Error while ${t} parsing`)},s.onerror=()=>{i(`Error while ${t}`)}}))},getleastPricedTriggerItem:function(e,t){let o;if(e.item_count&&t.for)if("products"===t.for.selectorType&&t.for.products&&t.for.products.length)e.items.forEach((e=>{t.for.products.some((t=>`${t.productId}`==`${e.product_id}`))&&(o&&e.line_pricee.tags&&e.tags.length&&e.tags.some((e=>t.for.products.some((t=>t.name===e))))));n&&n.length&&n.forEach((t=>{let n=e.items.find((e=>`${e.product_id}`==`${t.id}`));n&&(o&&n.line_price{(o&&e.line_price"popup-cart-addons"===e.upsellType))&&o&&o.isEnabled?n.getCart(window.location.hostname).then((r=>{if(n.log("prerenderCartOffer is Running"),r.item_count){let n=i.getDiscountFromStorage();!(n&&i.isDiscountValid(r,n))||n.code.includes("FUNDLL")||n.code.includes("CADDLL")||(e=!0),d.getApplicableOffer(t,r,["checkout-funnel","popup-cart-addons"]).then((t=>{t&&"popup-cart-addons"===t.upsellType&&o.isEnabled&&d.getFormattedWidgetInput(o,t,!e,r).then((e=>{localStorage.setItem("lb-upsell-cart-prerendered-data",JSON.stringify({widgetInput:e,setupOffer:t,expiry:new Date((new Date).getTime()+6e5).getTime()}))}))}))}})):n.isSnippetTesting()&&n.getCart(window.location.hostname).then((e=>{e.items[0].id=e.items[0].product_id,e.items[0].available=!0,r.showShopifyProductRecommendations(e.items[0],o).then((e=>{e.widget.isMultipleVariantsAdded=!0,n.ppaLog("Final offer input to wiget",e.offer),n.ppaLog("wiget settings",e.widget),n.ppaLog(JSON.stringify(e)),n.ppaLog("---------------"),localStorage.setItem("lb-upsell-cart-prerendered-data",JSON.stringify({widgetInput:e,setupOffer:{upsellType:"popup-cart-addons"}}))}))}))}},getPrerenderedData:function(){let e=localStorage.getItem("lb-upsell-cart-prerendered-data");if(e){e=JSON.parse(e),(new Date).getTime()>e.expiry&&(localStorage.removeItem("lb-upsell-cart-prerendered-data"),e=void 0)}return e},getFormattedTpaeOffer:function(e,t){return{boughtTogether:{offeredProducts:{products:e.map(((e,o)=>({discount:t,handle:e.handle,id:`gid://shopify/Product/${e.id}`,productId:`${e.id}`,sortNo:o+1,title:e.title})))}},for:{products:[],selectorType:"all"}}}}},730:(e,t,o)=>{const n=o(839),i=o(570),r=o(895),s=o(44);let d,l,a,c,u,p;e.exports={pcaWidgetLib:function(){let e={};function t(){let e=document.querySelector("lb-upsell-addon-popup");e&&e.addEventListener("pcaContinueClicked",(function(e){n.ppaLog("event",e.detail),e.detail.addedItems&&e.detail.addedItems.length?function(e,t,o){n.isPrerenderingDisabled=!0;let g={items:e.map((e=>({id:e.selectedVariantId,quantity:e.quantity||1})))};n.addItemsToCart(g).then((f=>{let m=n.getSetup(),h=a.offer.boughtTogether&&a.offer.boughtTogether.map((e=>e.id)),w=s.getleastPricedTriggerItem(d,c);r.pushEvent("offer-clicked",h,c.recordType,c,m,n.getWidgetSetup(m,"popup-cart-addons-widget"),!1,w,g.items);let b=[];if(t>0){let r=n.getSetup();b.push(i.getDiscountCode(r.myShopifyDomain,e,o,t,void 0,"popup-cart-addons-widget",c&&c.recordType))}else b.push(Promise.resolve(!0));Promise.all(b).then((o=>{let r=t>0&&o&&o[0]?o[0]:void 0;r&&r.code&&(r.endsAt=new Date((new Date).getTime()+6e4*(m.customDiscountEndTimeInMins||30)).getTime(),i.saveDiscountToStorage("popup-cart-addons-widget",e,r,void 0,w,a.offer.discounts.minimumCartAmount),i.addDiscountCodeToAllCartForms(!0,n.getCartForms(),r)),n.triggerCustomEvent({widgetType:"product-cart-addons-widget",discount:r}),n.ppaLog("addToCartReq status:",`${f}`),s.proceedToCheckout(e,r,l,p,"popup-cart-addons-widget",u,d)})).catch((t=>{n.ppaLog("Error while creating discount code.",t),n.triggerCustomEvent({widgetType:"product-cart-addons-widget",discount:{}}),n.ppaLog("addToCartReq status:",`${f}`),s.proceedToCheckout(e,void 0,l,p,"popup-cart-addons-widget",u,d)}))})).catch((e=>{n.ppaLog("Error - ppa widget addAllItemsToCart add to cart",e),s.proceedToCheckout(void 0,void 0,l,p,"popup-cart-addons-widget",u,d)}))}(e.detail.addedItems,e.detail.totalWithoutDiscount,e.detail.discounts,e.detail.forProduct):s.proceedToCheckout(void 0,void 0,l,p,"popup-cart-addons-widget",u,d)}))}function o(e,o){if(o.version>=15){let e=document.createElement("lb-upsell-addon-popup");document.body.append(e)}let i=document.querySelector("lb-upsell-addon-popup");if(i){i.renderAddonPopup(a),t();let s=a.offer.boughtTogether&&a.offer.boughtTogether.map((e=>e.id));r.pushEvent("offer-viewed",s,c.recordType,c,o,e,!1),n.ppaLog("Widget successfully rendered")}}return e.render=function(e,t,i,r,g,f,m,h){d=t,l=i,u=g,p=f,c=m;let w=n.getWidgetSetup(e,"popup-cart-addons-widget");h?h.widgetInput.offer&&h.widgetInput.offer.boughtTogether&&h.widgetInput.offer.boughtTogether.length?(c=h.setupOffer,a={offer:h.widgetInput.offer,widget:h.widgetInput.widget},n.log("rendering widget throught pre rendered data"),o(w,e)):s.proceedToCheckout(void 0,void 0,l,p,"popup-cart-addons-widget",u,d):s.getFormattedWidgetInput(w,m,r,t).then((t=>{n.log("widgetInputData:",t),t.offer&&t.offer.boughtTogether&&t.offer.boughtTogether.length?(a=t,o(w,e),n.ppaLog("Final offer input to wiget",t.offer),n.ppaLog("wiget settings",t.widget),n.ppaLog(JSON.stringify(t))):s.proceedToCheckout(void 0,void 0,l,p,"popup-cart-addons-widget",u,d)})).catch((e=>{n.log("Proceed to checkout",e),s.proceedToCheckout(void 0,void 0,l,p,"popup-cart-addons-widget",u,d)}))},e}}},873:(e,t,o)=>{const n=o(839),i=o(570),r=o(895),s=o(44);let d,l,a,c,u,p,g,f,m=e.exports={pufWidgetLib:function(){let e={};function t(e,t,o,i){if(e){let r=JSON.parse(JSON.stringify(e));return r.variants=r.variants.filter((e=>i&&i.length?e.available&&i.some((t=>t.id===`${e.id}`)):e.available)),r.available&&n.isImgAvailable(r)&&r.variants&&r.variants.length&&!function(e,t,o){return!(o&&o.isWindowRedirectUsedForCheckout&&"products"===t.for.selectorType&&t.for.products.some((t=>t.handle===decodeURI(e.handle))))&&e.variants.some((e=>l.items.some((t=>`${t.id}`==`${e.id}`))))}(e,t,o)?r:void 0}}function o(e,t){s.proceedToCheckout(e,t,a,f,"popup-upsell-funnel-widget",g,l)}function h(e,t,a,g,f){n.isPrerenderingDisabled=!0;let m=n.getPresentmentCurrency();var h;(h=e,new Promise(((e,t)=>{if(!h)return e(200);p=!0;let o={items:[{id:h.selectedVariantId,quantity:h.quantity}]};n.addItemsToCart(o).then((()=>{e(200)})).catch((t=>{e(t),console.log("Error while adding to cart",err)}))}))).then((p=>{let h=document.querySelector("lb-upsell-modal");if(200===p)if(f){if(n.upsellFunnelLog("Upsell funnel ended"),t&&t.length){let e=s.getleastPricedTriggerItem(l,u),t=c.upsellFunnel.offers.map((e=>e.offeredProduct&&e.offeredProduct.id||e.declinedOffer&&e.declinedOffer.offeredProduct&&e.declinedOffer.offeredProduct.id));r.pushEvent("offer-clicked",t,u.recordType,u,d,n.getWidgetSetup(d,"popup-upsell-funnel-widget"),!1,e)}if(a&&t&&t.length){let e=t.filter((e=>l.items.some((t=>`${t.id}`==`${e.selectedVariantId}`))));e&&e.length&&e.forEach((e=>{g+=Math.floor(Number(n.formatPrice(e.selectedVariantPrice/Number(m&&m.rate||1),!1)||0))})),i.getDiscountCode(d.myShopifyDomain,t,c.upsellFunnel.discounts,g,void 0,"popup-upsell-funnel-widget",u&&u.recordType).then((e=>{if(e&&e.code){e.endsAt=new Date((new Date).getTime()+6e4*(d.customDiscountEndTimeInMins||30)).getTime();let r=s.getleastPricedTriggerItem(l,u);i.saveDiscountToStorage("popup-upsell-funnel-widget",t,e,void 0,r,c.upsellFunnel.discounts.minimumCartAmount),i.addDiscountCodeToAllCartForms(!0,n.getCartForms(),e),o(t,e)}else o(t)})).catch((()=>{o(t)}))}else o(t)}else h.handleAddToCart(!0,p);else 422===p?(w=[{id:e.selectedVariantId}],new Promise(((e,t)=>{let o=new XMLHttpRequest;o.open("POST",`${n.getHostName()}/inventory`,!0),o.setRequestHeader("Content-Type","application/json; charset=UTF-8"),o.send(JSON.stringify({myShopifyDomain:d.myShopifyDomain,variants:w})),o.onload=function(){200===o.status?e(JSON.parse(o.responseText)):t(o.status)},o.onerror=e=>{n.upsellFunnelLog("Error while adding items to cart",e)}}))).then((t=>{if(t.productVariantInventory&&Object.keys(t.productVariantInventory).length){let o;const n=t.productVariantInventory[e.selectedVariantId];n&&"DENY"===n.inventoryPolicy&&n.tracked&&Number(e.quantity)>=Number(n.available)&&(o=Number(n.available)),h.handleAddToCart(!1,p,o)}})).catch((e=>{console.log("Error while fetching inventory data",e),o()})):(console.log("Unknown error while adding items to cart.",p),o());var w}))}function w(e,t){if(c=e,u=t,n.upsellFunnelLog("widgetInput:",JSON.stringify(e)),n.upsellFunnelLog("Rendering widget"),d.version>=15){let e=document.createElement("lb-upsell-modal");document.body.append(e)}let i=document.querySelector("lb-upsell-modal");i?(i.renderModal(e),function(e){e.addEventListener("upsellFunnelAddToCart",(function(e){e.detail&&e.detail&&(n.upsellFunnelLog("event.detail:",e.detail),h(e.detail.acceptedProduct,e.detail.acceptedProducts,e.detail.discounts,e.detail.totalWithoutDiscount,e.detail.isUpsellFunnelEnded))}))}(i)):(n.upsellFunnelLog("pufWidget not found"),o());let s=e.upsellFunnel.offers.map((e=>e.offeredProduct&&e.offeredProduct.id));r.pushEvent("offer-viewed",s,t.recordType,t,d,n.getWidgetSetup(d,"popup-upsell-funnel-widget"),!1),n.upsellFunnelLog("Widget successfully rendered")}return e.getPreRenderedWidgetInput=function(){let e=localStorage.getItem("lb-upsell-prerendered-data");return e=e?JSON.parse(e):void 0,e},e.initiateOffer=function(e,i,r,s,a){if(p)n.upsellFunnelLog("Ignoring as addtocart req is forced");else{n.upsellFunnelLog("Best offer:",a),function(e,o,i){return new Promise(((r,s)=>{let a=n.getPresentmentCurrency(),c=i&&o.upsellFunnel.discounts&&o.upsellFunnel.discounts.isEnabled&&o.upsellFunnel.discounts;if(c&&Number(c.minimumCartAmount)>0){let e=100*Number(c.minimumCartAmount)*Number(a&&a.rate||1);e>l.total_price&&(n.upsellFunnelLog(`Discounts will not be shown due to minimumCartAmount cond. minimumCartAmount - ${e}, cart total - ${l.total_price}`),c=void 0)}let u={offers:[],discounts:c,overrideWidgeTitle:o.overrideWidgeTitle},p={styles:e.styles,content:e.content,imageResolution:e.imageResolution,isQtyPickerHidden:e.isQtyPickerHidden,metadata:{isAmountNoDecimals:d&&d.isAmountNoDecimals,shopMoneyInEmailsFormat:d&&d.shopMoneyInEmailsFormat,shopCurrencyCode:d&&d.shopCurrencyCode,presentmentCurrency:a,isUnitPriceShown:d&&d.isUnitPriceShown,setupVersion:d.version,variantsGroupSeperator:d.variantsGroupSeperator}};if(d.shopLocales&&d.shopLocales.length>1){n.upsellFunnelLog("Checking shoplocale");const t=n.getCurrentLocale(),i=d.shopLocales.find((e=>e.primary));if(i&&i.locale!==t&&e.translations&&e.translations[t]){n.upsellFunnelLog("Replacing primaery locale");const o=p.content.countDownTimerMins&&JSON.parse(JSON.stringify(p.content.countDownTimerMins)),i=p.content.countDownTimerSecs&&JSON.parse(JSON.stringify(p.content.countDownTimerSecs));n.upsellFunnelLog("countDownTimerMins",o),p.content=e.translations[t],p.content.countDownTimerMins=o,p.content.countDownTimerSecs=i,n.upsellFunnelLog("formattedWidget.content",p.content)}if(o.upsellFunnel.offers&&o.upsellFunnel.offers.length&&o.translations&&o.translations[t]&&(o.translations[t].name&&(o.upsellFunnel.offers[0].name=o.translations[t].name),o.translations[t].discountTitle&&(o.upsellFunnel.offers[0].discountTitle=o.translations[t].discountTitle),o.translations[t].customDescription&&(o.upsellFunnel.offers[0].customDescription=o.translations[t].customDescription),o.upsellFunnel.offers.length>1))for(let e=1;e<=o.upsellFunnel.offers.length;e++)o.upsellFunnel.offers[e]&&(o.translations[t][`name-${e+1}a`]&&(o.upsellFunnel.offers[e].name=o.translations[t][`name-${e+1}a`]),o.translations[t][`discountTitle-${e+1}a`]&&(o.upsellFunnel.offers[e].discountTitle=o.translations[t][`discountTitle-${e+1}a`]),o.translations[t][`customDescription-${e+1}a`]&&(o.upsellFunnel.offers[e].customDescription=o.translations[t][`customDescription-${e+1}a`]),o.upsellFunnel.offers[e].declinedOffer&&(o.translations[t][`name-${e+1}b`]&&(o.upsellFunnel.offers[e].declinedOffer.name=o.translations[t][`name-${e+1}b`]),o.translations[t][`discountTitle-${e+1}b`]&&(o.upsellFunnel.offers[e].declinedOffer.discountTitle=o.translations[t][`discountTitle-${e+1}b`]),o.translations[t][`customDescription-${e+1}b`]&&(o.upsellFunnel.offers[e].declinedOffer.customDescription=o.translations[t][`customDescription-${e+1}b`])))}let g=[];o.upsellFunnel.offers.forEach((e=>{e.offeredProduct&&e.offeredProduct.handle&&!g.some((t=>t===e.offeredProduct.handle))&&g.push(e.offeredProduct.handle),e.declinedOffer&&e.declinedOffer.offeredProduct&&!g.some((t=>t===e.declinedOffer.offeredProduct.handle))&&g.push(e.declinedOffer.offeredProduct.handle)})),n.getProducts(g).then((n=>{let i=o.upsellFunnel.offers&&o.upsellFunnel.offers.length&&o.upsellFunnel.offers[0]&&o.upsellFunnel.offers[0].isVariantsSelection;JSON.parse(JSON.stringify(o)).upsellFunnel.offers.forEach((r=>{r.offeredProduct&&(r.offeredProduct=t(n.find((e=>`${e.id}`===r.offeredProduct.productId)),o,e,i&&r.offeredProduct.limitVariants)),r.declinedOffer&&r.declinedOffer.offeredProduct&&(r.declinedOffer.offeredProduct=t(n.find((e=>`${e.id}`===r.declinedOffer.offeredProduct.productId)),o,e,i&&r.declinedOffer.offeredProduct.limitVariants)),(r.offeredProduct||r.declinedOffer&&r.declinedOffer.offeredProduct)&&(0===u.offers.length?r.offeredProduct&&u.offers.push(r):u.offers.push(r))})),r({widget:p,upsellFunnel:u})})).catch((e=>{console.log("Err while get products",e),s(e)}))}))}(n.getWidgetSetup(e,"popup-upsell-funnel-widget"),a,r).then((e=>{n.log("widgetInput:",e),e.upsellFunnel&&e.upsellFunnel.offers[0]&&e.upsellFunnel.offers[0].offeredProduct&&e.widget?s?w(e,a):(n.upsellFunnelLog("Widget input"),n.upsellFunnelLog(JSON.stringify(e)),function(e,t){localStorage.setItem("lb-upsell-prerendered-data",JSON.stringify({widgetInput:e,setupOffer:t}))}(e,a)):(n.upsellFunnelLog("Coudn't find offer"),s&&(n.upsellFunnelLog("Proceeding to checkout"),o()))})).catch((e=>{console.log("Error while getFormattedWidgetInput",e),o()}))}},e.render=function(e,t,o,i,r,s,c){d=e,l=t,a=o,g=r,f=s,n.upsellFunnelLog("Puf render called,","isDiscountShown:",i);let u=m.pufWidgetLib().getPreRenderedWidgetInput();n.upsellFunnelLog("preRenderedData",u),u?(n.upsellFunnelLog("Rendeering widget with prerendered widgetInput"),w(u.widgetInput,u.setupOffer)):(n.upsellFunnelLog("No prerendered widgetInput found, initating offer."),m.pufWidgetLib().initiateOffer(e,t,i,!0,c))},e}}},818:(e,t,o)=>{const n=o(839),i=o(44),r=o(895),s=o(721);let d,l,a,c,u,p,g,f;e.exports={TpaeWidgetLib:function(){let e={};function t(e){let t=n.getWidgetSetup(a,"tq-page-addon-embedded-widget"),o=c.offer.boughtTogether&&c.offer.boughtTogether.map((e=>e.id));r.pushEvent(e,o,l.isRecommendationOffer?g&&g.product_id:l.recordType,l,a,t,l.isRecommendationOffer,g,f)}function o(e,o,r,s){n.ppaLog("added widget to custom selector");let a=document.querySelector(e);if(a){a.insertAdjacentHTML(o," \n \n");let c=document.querySelector("lb-tq-page-upsell");c?(c.widget=r.widget,c.offer=r.offer,n.ppaLog(`Widget successfully added to selector , ${e}`),function(e,o){e.addEventListener("tqaeOrderClicked",(function(e){n.ppaLog("emited events",e,e.detail),f=e.detail.products,t("offer-clicked"),i.getOrderQueryResponse({order:e.detail,myShopifyDomain:d,customerId:p&&p.customer_id,orderId:u,recordType:l.recordType},o.orderType).then((e=>{"editOrder"===o.orderType?window.location.reload():(window.open(e.url,o.orderRedirectAction&&"redirect_same_tab"===o.orderRedirectAction||!o.orderRedirectAction?"_self":"_blank").focus(),n.removeExistingWidget("lb-tq-page-upsell"))})).catch((e=>{n.ppaLog("Error while getting draft order",e)}))})),e.addEventListener("tqaeModalProductClicked",(function(e){n.ppaLog("emited events",e,e.detail),t("offer-clicked")})),e.addEventListener("tqaeOfferExpired",(function(e){let t=document.querySelector(".lb-tpae-confirm-button");t?t.click():n.removeExistingWidget("lb-tq-page-upsell"),localStorage.setItem("lb-upsell-Tpae-Expired",!0)}))}(c,s)):n.ppaLog("tpaeWidget not found"),t("offer-viewed")}else n.ppaLog(`Could not find selector, ${e}`)}function m(){return window.innerWidth<=768}function h(e,t,r){let s=i.getleastPricedTriggerItem(r,l);i.getFormattedWidgetInput(e,t,void 0,void 0,s).then((t=>{n.ppaLog("Tpae - widget input:",t),c=t,t.offer&&t.offer.boughtTogether&&t.offer.boughtTogether.length?(n.ppaLog("---------------"),function(e,t){n.removeExistingWidget("lb-tq-page-upsell");let i=m()?t.position.mobile.selector:t.position.desktop.selector,r=m()?t.position.mobile.insertPosition:t.position.desktop.insertPosition;n.ppaLog("----------Positioning widget----------"),o(i,r,e,t);let s=document.querySelector(".step__footer__continue-btn");s&&n.setBtnCSS(s,!0)}(t,e)):(n.ppaLog("Not enough products to position widgets"),n.ppaLog("---------------"))})).catch((e=>{n.ppaLog("Error while getFormattedWidgetInput",e)}))}function w(e,t){let o=Number(e.maxItemsInOffer)>0?e.maxItemsInOffer:2,r=i.getleastPricedTriggerItem(t,{for:{selectorType:"all"}});g=r,s.getShopifyProductRecomendation(r.product_id,o).then((t=>{if(n.log("ProductRecommendations result:",t),t.products.length>0){let o;e.useShopifyProductRecommendations&&e.recommendationDiscount&&e.recommendationDiscount.isEnabled&&(o=e.recommendationDiscount);let n=i.getFormattedTpaeOffer(t.products,o);n.tpaeDiscounts={isEnabled:e.useShopifyProductRecommendations,discountType:"byProducts"},l=n,l.isRecommendationOffer=!0,h(e,n)}}))}function b(){return a&&a.offers&&a.offers.length&&a.offers.some((e=>"tq-page-upsell"===e.upsellType))}return e.render=function(e){d=e.myShopifyDomain,a=e,p=function(){let e=window.Shopify&&window.Shopify.checkout||{};return e&&e.line_items&&e.line_items.length&&e.line_items.forEach((e=>{e.id=e.product_id})),e}();let t=n.getWidgetSetup(a,"tq-page-addon-embedded-widget");i.isThankyouPage()&&(n.ppaLog("thankyou page found"),(t.useShopifyProductRecommendations||b())&&new Promise(((e,t)=>{i.getOrderQueryResponse({myShopifyDomain:d,orderId:p.order_id}).then((t=>{let o=t.products;u=t.orderNumber,o&&o.length>0&&!function(e){return e&&e.orderTags&&e.orderTags.length&&e.orderTags.some((e=>e.includes("lb-upsell-parent-order")))}(t)?e({items:o,item_count:o&&o.length}):e(void 0)})).catch((e=>{n.ppaLog("Error while getting order",e),t("Error while getting current Order")}))})).then((e=>{e?b()?i.getApplicableOffer(a,e,["tq-page-upsell"]).then((o=>{n.ppaLog("Best offer:",o),o?(l=o,h(t,o,e)):(n.ppaLog("Coudn't find Tpae offer"),t.useShopifyProductRecommendations&&w(t,e))})).catch((e=>{n.ppaLog("Error while finding Tpae offer",e)})):(n.ppaLog("No offers found"),t.useShopifyProductRecommendations&&w(t,e)):n.ppaLog("upsold order found, so tpae not rendered")})).catch((e=>{n.ppaLog("Offer not rendered. error while getting current order.",e)})))},e}}},655:(e,t,o)=>{const n=o(839),i=o(570);let r=e.exports={isCartUpdateNotRequired:function(){if(void 0!==window.lbUpsellComponents)return window.lbUpsellComponents.isCartUpdateNotRequired},isCartUpdateForced:function(){if(void 0!==window.lbUpsellComponents)return window.lbUpsellComponents.isCartUpdateForced},addCartUpdateListener:function(){window.addEventListener("lb-upsell-added",(function(e){if(n.log("Cart update listener added"),(e.detail&&"ajax"===e.detail.currentAddToCartActionSetup&&"product-page-addon-widget"===e.detail.widgetType||r.isCartUpdateForced())&&!r.isCartUpdateNotRequired()){if(n.log("Updating cart from cart update listener"),"function"==typeof window.SLIDECART_UPDATE)try{window.SLIDECART_UPDATE()}catch(e){console.log("Error while updating cart",e)}if(void 0!==window.theme&&void 0!==window.theme.ajaxCart&&"function"==typeof window.theme.ajaxCart.update)try{window.theme.ajaxCart.update()}catch(e){console.log("Error while updating cart",e)}if("function"==typeof window.icartCartActivityEvent)try{window.icartCartActivityEvent()}catch(e){console.log("Error while updating cart",e)}try{document.dispatchEvent(new CustomEvent("cart:refresh"))}catch(e){console.log("Error while updating cart",e)}try{document.documentElement.dispatchEvent(new CustomEvent("cart:refresh",{bubbles:!0}))}catch(e){console.log("Error while updating cart",e)}if(void 0!==window.HsCartDrawer&&"function"==typeof window.HsCartDrawer.updateSlideCart&&globalDebounce("hscartdrawer",(function(){try{HsCartDrawer.updateSlideCart()}catch(e){console.log("Error while updating cart",e)}}),100),void 0!==window.HS_SLIDE_CART_OPEN&&"function"==typeof window.HS_SLIDE_CART_OPEN&&globalDebounce("hscartdraweropen",(function(){try{window.HS_SLIDE_CART_OPEN()}catch(e){console.log("Error while updating cart",e)}}),100),"undefined"!=typeof theme&&void 0!==theme.Cart&&"function"==typeof theme.Cart.updateCart)try{theme.Cart.updateCart()}catch(e){console.log("Error while updating cart",e)}if("function"==typeof window.updateMiniCartContents)try{window.updateMiniCartContents()}catch(e){console.log("Error while updating cart",e)}if("function"==typeof window.loadEgCartDrawer)try{window.loadEgCartDrawer()}catch(e){console.log("Error while updating cart",e)}try{document.dispatchEvent(new CustomEvent("cart:build"))}catch(e){console.log("Error while updating cart",e)}try{document.dispatchEvent(new CustomEvent("cart:open"))}catch(e){console.log("Error while updating cart",e)}try{document.documentElement.dispatchEvent(new CustomEvent("product:added",{bubbles:!0,detail:{source:"lb-upsell",quantity:"remove"==e.detail.addToCartAction?-1:1}}))}catch(e){console.log("Error while updating cart",e)}try{void 0!==window.cart&&void 0!==window.cart.getCart&&void 0!==window.cart.openCartDropdown&&(window.cart.getCart(),window.cart.openCartDropdown())}catch(e){console.log("Error while updating cart",e)}try{void 0!==window.ajaxCart&&window.ajaxCart.load()}catch(e){console.log("Error while updating cart",e)}try{document.dispatchEvent(new CustomEvent("obsidian:upsell:refresh")),document.dispatchEvent(new CustomEvent("obsidian:upsell:open"))}catch(e){console.log("Error while updating cart",e)}var t=document.getElementById("site-cart");if(null!==t)try{t.show()}catch(e){console.log("Error while updating cart",e)}if("undefined"!=typeof CartJS&&"function"==typeof CartJS.getCart)try{CartJS.getCart()}catch(e){console.log("Error while updating cart",e)}if(void 0!==window.SLIDECART_UPDATE)try{window.SLIDECART_UPDATE()}catch(e){console.log("Error while updating cart",e)}if(void 0!==window.SLIDECART_OPEN&&setTimeout((function(){try{window.SLIDECART_OPEN()}catch(e){console.log("Error while updating cart",e)}}),500),"undefined"!=typeof Shopify&&void 0!==Shopify.theme&&void 0!==Shopify.theme.jsAjaxCart&&"function"==typeof Shopify.theme.jsAjaxCart.updateView)try{Shopify.theme.jsAjaxCart.updateView()}catch(e){console.log("Error while updating cart",e)}if(void 0!==window.theme&&void 0!==window.theme.MiniCart&&"function"==typeof window.theme.MiniCart.update)try{theme.MiniCart.update()}catch(e){console.log("Error while updating cart",e)}if(void 0!==window.openCart&&void 0!==window.monster_setCartItems)try{fetch("/cart.js").then((function(e){return e.json()})).then((function(e){window.openCart(),window.monster_setCartItems(e.items)}))}catch(e){console.error(e)}if(void 0!==window.Shopify&&void 0!==window.Shopify.onCartUpdate)try{window.Shopify.onCartUpdate()}catch(e){console.error(e)}try{var o=document.querySelector("cart-notification")||document.querySelector("cart-drawer");if(null!==o&&"function"==typeof o.renderContents)fetch("/cart?sections=cart-notification-product,cart-notification-button,cart-icon-bubble",{method:"GET",cache:"no-cache",credentials:"same-origin",headers:{"Content-Type":"application/json"}}).then((function(e){try{return e.clone().json().then((function(e){fetch("/cart.js").then((function(e){return e.json()})).then((function(t){try{if(t&&t.item_count){var n={sections:e,key:t.items[0]&&t.items[0].key};o.renderContents(n)}else{const e=document.querySelector(".cart-count-bubble");e&&e.remove()}}catch(e){console.error(e)}}))}))}catch(e){console.error(e)}}))}catch(e){console.error(e)}try{window.dispatchEvent(new Event("update_cart"))}catch(e){console.log("Error while updating cart",e)}}n.getCart(window.location.hostname).then((e=>{i.process(n.getSetup(),e)}))}))}}},582:(module,__unused_webpack_exports,__webpack_require__)=>{const utils=__webpack_require__(839),discounts=__webpack_require__(570),pufWidget=__webpack_require__(873),pcaWidget=__webpack_require__(730),cartPageUtils=__webpack_require__(44);let _checkoutHandler=module.exports={registerListeners:function(e,t){let o=utils.getSetup(),n=utils.getWidgetSetup(o,"popup-upsell-funnel-widget"),i=utils.getWidgetSetup(o,"product-page-cross-sell-embedded-widget"),r=utils.getWidgetSetup(o,"product-page-addon-widget"),s=utils.getWidgetSetup(o,"popup-cart-addons-widget"),d=discounts.getDiscountFromStorage();if(i&&i.isEnabled||n&&n.isEnabled||r&&r.isEnabled||s&&s.isEnabled||d)if(e&&t){let e=t.querySelectorAll(o.checkoutBtnSelector);e.length&&utils.addCheckoutListenerToElements(e,"lb-upsell-mutation-checkout-listener",_checkoutHandler.handleCheckout),t&&t.matches&&t.matches(o.checkoutBtnSelector)&&utils.addCheckoutListenerToElements([t],"lb-upsell-mutation-checkout-listener",_checkoutHandler.handleCheckout)}else if(o.checkoutBtnSelector){let e=document.querySelectorAll(o.checkoutBtnSelector);e.length&&utils.addCheckoutListenerToElements(e,"lb-upsell-custom-checkout-listener",_checkoutHandler.handleCheckout)}else{let e=utils.getCartForms(),t=e.map((e=>e.getAttribute("id")));if(e&&e.length){if(utils.addCartSubmitClickListener(e[0],t,_checkoutHandler.handleCheckout),e.length>1){e=e.slice(1,5);for(let o of e)utils.addCartSubmitClickListener(o,t,_checkoutHandler.handleCheckout)}utils.upsellFunnelLog("Registered cart form listeners")}if(o.version>=5){let e=document.querySelectorAll('a[href="/checkout"]');utils.log("checkoutAnchors",e);for(let t=0;t14&&o&&e&&e.tagName&&"a"===e.tagName.toLowerCase()&&"/checkout"===e.getAttribute("href")){utils.upsellFunnelLog("window redirecting because of anchor tag");let e=utils.getRootRoute();window.location.href=e&&"/"!==e?`${e}cart/checkout${o?`?discount=${o.code}`:""}`:"/cart/checkout"+(o?`?discount=${o.code}`:"")}else if(utils.isCheckoutClickForced=!0,e.disabled=!1,e&&o&&o.code)if(n&&n.isDealeasyIntegrated&&window.lbDealeasy&&"function"==typeof window.lbDealeasy.applyDiscountsToCart)await window.lbDealeasy.applyDiscountsToCart([o.code],"selleasy"),e.click();else if(window.lbUpsellComponents&&window.lbUpsellComponents.isDiscountFetchPrevented)e.click();else{let t=utils.getRootRoute();fetch(`https://${window.location.hostname}${t||"/"}discount/${o.code}`).then((t=>{e.click()})).catch((t=>{utils.log("Error while fetching discount",t),e.click()}))}else e.click();if(t){const e={acceptedProducts:void 0,discount:void 0};utils.triggerCustomEvent(e,"selleasy-checkout-popup-completed")}},renderSelleasyCheckoutPopup:function(){_checkoutHandler.handleCheckout(void 0,void 0,void 0,!1,!0)},checkTAC:function(e){if(e&&e.TACSelectors&&(e.TACSelectors.cartDrawer||e.TACSelectors.cartPage)){let t=window.location.pathname.includes("/cart")?e.TACSelectors.cartPage&&document.querySelector(e.TACSelectors.cartPage):e.TACSelectors.cartDrawer&&document.querySelector(e.TACSelectors.cartDrawer);return!t||"INPUT"!==t.tagName||"checkbox"!==t.type||t.checked}return!0},handleCheckout:function(e,t,o,n,i){let r=utils.getSetup();if(_checkoutHandler.checkTAC(r))if(window.lbUpsellComponents&&window.lbUpsellComponents.isDefaultCheckoutListenerIgnored&&n)console.log("Not rendering as called by our own listeners");else{let n=discounts.getDiscountFromStorage();if(n||r.offers&&r.offers.length&&r.offers.some((e=>"checkout-funnel"===e.upsellType||"popup-cart-addons"))||utils.isSnippetTesting()){"undefined"==typeof handleUSCSKCheckout||handleUSCSKCheckout()?utils.isCheckoutClickForced||(utils.upsellFunnelLog("Checkout click handler called."),e&&(_checkoutHandler.preventSubmit(e),e.srcElement&&"checkout"===e.srcElement.getAttribute("name")&&(t=e.srcElement)),utils.getCart(window.location.hostname).then((e=>{discounts.validateAndFetchDiscount(e);let s,d=[];if(utils.isDiscountStacked()){const t=discounts.getStackDiscountValidationData(e);t&&t.invalidDiscountCodes&&t.invalidDiscountCodes.length?(t.invalidDiscountCodes.forEach((e=>{utils.removeStackDiscount(e),d.push(discounts.deleteDiscountCode(r.myShopifyDomain,e.priceRuleId,e.discountCodeId)),n&&e.code===n.code&&(utils.log("Deleting discount from storage",e.code),localStorage.removeItem("lb-upsell-offer-discount"))})),localStorage.setItem("lb-upsell-offer-discount-stack",JSON.stringify(t.validDiscountCodes))):d.push(Promise.resolve(!0))}else{let t=discounts.getDiscountFromStorage();const o=t&&discounts.isDiscountValid(e,t);o&&(t.code.includes("FUNDLL")||t.code.includes("CADDLL")||(s=!0),utils.upsellFunnelLog("Discount is valid, adding to form in checkoutSubmitHandler",t.code),discounts.addDiscountCodeToAllCartForms(!0,utils.getCartForms(),t)),t&&t.code&&!o?(utils.log("Discount code is not valid, calling removeDicountCodeFromAllCartForms"),discounts.removeDicountCodeFromAllCartForms(t.code),d.push(discounts.deleteDiscountCode(r.myShopifyDomain,t.priceRuleId,t.discountCodeId)),utils.log("Deleting discount from storage"),localStorage.removeItem("lb-upsell-offer-discount")):d.push(Promise.resolve(!0))}Promise.all(d).then((d=>{const l=!s||utils.isDiscountStacked();let a=utils.getWidgetSetup(r,"popup-upsell-funnel-widget"),c=utils.getWidgetSetup(r,"popup-cart-addons-widget");const u=cartPageUtils.getPrerenderedData();a&&a.isEnabled||c&&c.isEnabled?utils.isCartPage()&&u&&u.widgetInput.offer?(utils.log("prerenderedData:",u),"popup-cart-addons"===u.setupOffer.upsellType&&c&&c.isEnabled&&!_checkoutHandler.isFormIgnored(o)?pcaWidget.pcaWidgetLib().render(r,e,t,l,s,i,void 0,u):_checkoutHandler.proceedToCheckout(t,i,s&&n)):cartPageUtils.getApplicableOffer(r,e,["checkout-funnel","popup-cart-addons"]).then((d=>{utils.log("best offer:",d),d?"popup-cart-addons"===d.upsellType&&c&&c.isEnabled&&!_checkoutHandler.isFormIgnored(o)?pcaWidget.pcaWidgetLib().render(r,e,t,l,s,i,d):"checkout-funnel"===d.upsellType&&a&&a.isEnabled&&!_checkoutHandler.isFormIgnored(o)?pufWidget.pufWidgetLib().render(r,e,t,l,s,i,d):(utils.log("proceeding to checkout:",d),_checkoutHandler.proceedToCheckout(t,i,s&&n)):(utils.log("offer not found, proceeding to checkout:",d),_checkoutHandler.proceedToCheckout(t,i,s&&n))})).catch((e=>{console.log("Error while getApplicableOffer")})):(utils.log("puf/pca widget not enabled, proceeding to checkout"),_checkoutHandler.proceedToCheckout(t,i,s&&n))}))})).catch((e=>{utils.upsellFunnelLog("Error while handling checkout",e),_checkoutHandler.proceedToCheckout(t,i)}))):(console.log("Integrated app returned false"),e&&_checkoutHandler.preventSubmit(e))}else utils.upsellFunnelLog("No discount/funnel offers, so not preventing checkout btn"),_checkoutHandler.proceedToCheckout(t,i)}else console.log("Terms and condition not checked.")}}},150:e=>{e.exports={HOST_NAME:"https://upsell-app.logbase.io",IS_LOGS_REQUIRED:"false",API_VERSION:"2024-10"}},570:(e,t,o)=>{const n=o(150),i=o(839);let r,s=e.exports={getDiscountCodeQuery:function(){return"\n mutation cartDiscountCodesUpdate($id: ID!, $discountCodes:[String!]) {\n cartDiscountCodesUpdate(cartId: $id, discountCodes: $discountCodes) {\n cart {\n id\n }\n userErrors {\n field\n message\n }\n }\n }"},processStoreFrontAPI:async function(e,t,o){let i="\n query cart($id: ID!) {\n cart(id: $id) {\n id\n }\n }",d=e&&{id:e.token};o&&(i=s.getDiscountCodeQuery(),d={discountCodes:[t],id:o});var l=new XMLHttpRequest;l.open("POST",`https://${window.location.hostname}/api/${n.API_VERSION}/graphql.json`,!0),l.setRequestHeader("Content-Type","application/json; charset=UTF-8"),l.setRequestHeader("X-Shopify-Storefront-Access-Token",r.storeFrontAccessToken),l.setRequestHeader("Access-Control-Allow-Origin","*"),l.send(JSON.stringify({query:i,variables:d})),l.onload=()=>{if(200===l.status){let e=JSON.parse(l.responseText);e&&e.data&&e.data.cart&&e.data.cart.id&&s.processStoreFrontAPI(void 0,t,e.data.cart.id)}else console.log("Error while getting cart")},l.onerror=()=>{console.log("Error while getting cart")}},handleDiscountAfterClick:async function(){window.lbUpsellComponents&&void 0!==window.lbUpsellComponents.validateAndFetchDiscount&&i.getCart(window.location.hostname).then((e=>{window.lbUpsellComponents.validateAndFetchDiscount(e)})).catch((e=>{i.log("Error while fetching cart: discount",e)}))},validateAndFetchDiscount:async function(e,t=void 0,o=!1){r=i.getSetup();try{if(!t){let o=s.getDiscountFromStorage(),n=o?s.isDiscountValid(e,o):void 0;n?t=o.code:o&&!n&&window&&(window.lbDiscountCreatedAt&&window.lbDiscountCreatedAt-(new Date).getTime()>5e3||void 0===window.lbDiscountCreatedAt)&&(s.deleteDiscountCode(r.myShopifyDomain,o.priceRuleId,o.discountCodeId),localStorage.removeItem("lb-upsell-offer-discount"))}i.log(`Validating code, ${t}.`);let n=i.getCookieValue("cart");if(t&&n)if(n=`gid://shopify/Cart/${n}`,e.token=n,r&&r.isDealeasyIntegrated&&window.lbDealeasy&&"function"==typeof window.lbDealeasy.applyDiscountsToCart)window.lbDealeasy.applyDiscountsToCart([t],"selleasy",n);else if(!window.lbUpsellComponents||!window.lbUpsellComponents.isDiscountFetchPrevented){let d=i.getRootRoute();fetch(`https://${window.location.hostname}${d||"/"}discount/${t}`),r&&r.storeFrontAccessToken&&s.processStoreFrontAPI(e,t,!!o&&n)}}catch(e){i.log("Error while processing: validateAndFetchDiscount",e)}},fetchDiscount:async function(e){let t=i.getSetup();if(t&&t.version>=15||window.lbUpsellComponents&&window.lbUpsellComponents.isDiscountFetchForced){let t=i.getCookieValue("discount_code");if(!t||t&&["FUNDLL","BUNDLL","ADDDLL","CADDLL"].some((e=>t.includes(e)))){if("function"==typeof fetch){let t=i.getRootRoute();i.log(`Fetching discount code, https://${window.location.hostname}${t||"/"}discount/${e.code}`),fetch(`https://${window.location.hostname}${t||"/"}discount/${e.code}`)}}else i.log("Existing cookie is present, so not fetching discount",t)}},getDiscountCode:function(e,t,o,n,r,s,d,l=void 0,a){return new Promise(((c,u)=>{let p=new XMLHttpRequest;"free_shipping"===o.type?(p.open("POST",`${i.getHostName()}/discounts/createShippingDiscountCode`,!0),p.setRequestHeader("Content-Type","application/json; charset=UTF-8"),p.setRequestHeader("Access-Control-Allow-Origin","*"),p.send(JSON.stringify({myShopifyDomain:e,minimumPurchaseValue:n,widgetType:s,recordType:d,triggerProduct:a}))):(p.open("POST",`${i.getHostName()}/discounts/createDiscountCode`,!0),p.setRequestHeader("Content-Type","application/json; charset=UTF-8"),p.setRequestHeader("Access-Control-Allow-Origin","*"),p.send(JSON.stringify({myShopifyDomain:e,products:t,minimumPurchaseValue:n,cheapestProduct:r,widgetType:s,recordType:d,triggerProduct:a}))),p.onload=()=>{if(i.log("discCodeReq.responseText",p.responseText),200===p.status){let e=JSON.parse(p.responseText),t=i.getSetup();if(t&&t.isDealeasyIntegrated&&window.lbDealeasy&&"function"==typeof window.lbDealeasy.applyDiscountsToCart)c(e),window.lbDealeasy.applyDiscountsToCart([e.code],"selleasy");else if(l)c(e);else{let t=i.getRootRoute();window.lbUpsellComponents&&window.lbUpsellComponents.isDiscountFetchPrevented?c(e):fetch(`https://${window.location.hostname}${t||"/"}discount/${e.code}`).then((()=>{c(e)})).catch((()=>{c(e)}))}}else u("Error while createDiscountCode")},p.onerror=()=>{u("Error while createDiscountCode")}}))},deleteDiscountCode:function(e,t,o){return new Promise(((n,r)=>{let s=new XMLHttpRequest;o?(s.open("POST",`${i.getHostName()}/discounts/deleteShippingDiscountCode`,!0),s.setRequestHeader("Content-Type","application/json; charset=UTF-8"),s.setRequestHeader("Access-Control-Allow-Origin","*"),s.send(JSON.stringify({myShopifyDomain:e,discountCodeId:o}))):(s.open("POST",`${i.getHostName()}/discounts/deleteDiscountCode`,!0),s.setRequestHeader("Content-Type","application/json; charset=UTF-8"),s.setRequestHeader("Access-Control-Allow-Origin","*"),s.send(JSON.stringify({myShopifyDomain:e,priceRuleId:t}))),s.timeout=3e3,s.onload=()=>{i.log("deleteDiscountCode responseText",s.responseText),200===s.status||console.log("Error while deleteDiscountCode",s.status),n(s.status)},s.onerror=()=>{console.log("Error while deleteDiscountCode",s.status),n(s.status)},s.ontimeout=()=>{console.log("deleteDiscountCode timeout",s.status),n(s.status)}}))},isDiscountShown:function(e,t){let o=s.getDiscountFromStorage(),n=o?s.isDiscountValid(t,o):void 0;return!o||o&&o.forProductId===e||!n},isWidgetDiscountValid:function(e,t){let o=s.getDiscountFromStorage();return o&&o.code&&o.code.includes(t)&&s.isDiscountValid(e,o)},isDiscountValid:function(e,t){let o=!0,n=(new Date).getTime();if(e&&e.item_count&&t&&t.products&&t.products.length&&n{e.items.some((e=>`${e.id}`==`${t.selectedVariantId}`))||(o=!1)})),o&&t&&t.forProductVariants&&t.forProductVariants.length&&(o=t.forProductVariants.some((t=>e.items.some((e=>`${e.id}`==`${t}`))))),o&&t&&t.leastPricedTriggerItem){const n=e.items.filter((e=>`${e.product_id}`==`${t.leastPricedTriggerItem.product_id}`));if(n&&n.length){let e=t.products.find((e=>`${e.id}`==`${n[0].product_id}`));e&&(i.log("triggerItemInOfferedProduct check",n[0].quantity>e.quantity),o=n.length>1||n[0].quantity>e.quantity)}else i.log("For product is not in cart, so discount is not valid,"),o=!1}o&&t&&t.minimumCartAmount&&Number(t.minimumCartAmount)>0&&Number(t.minimumCartAmount)>Number(e.items_subtotal_price/100)&&(i.log("cart subtotal is less than minimumCartAmount, so discount is not valid",t.minimumCartAmount),o=!1)}else o=!1;return o},saveDiscountToStorage:function(e,t,o,n,r,d){const l={products:t,code:o.code,priceRuleId:o.priceRuleId,discountCodeId:o.discountCodeId,endsAt:o.endsAt,forProductId:e,forProductVariants:n,leastPricedTriggerItem:r,minimumCartAmount:d};window&&(window.lbDiscountCreatedAt=(new Date).getTime()),localStorage.setItem("lb-upsell-offer-discount",JSON.stringify(l)),s.saveStackDiscountToStorage(l),i.applyStackDiscount(l)},getDiscountFromStorage:function(){let e=localStorage.getItem("lb-upsell-offer-discount");return e?JSON.parse(e):void 0},saveStackDiscountToStorage:function(e){if(i.isDiscountStacked()){let t=s.getStackDiscountFromStorage();t.push(e),localStorage.setItem("lb-upsell-offer-discount-stack",JSON.stringify(t))}},getStackDiscountFromStorage:function(){const e=localStorage.getItem("lb-upsell-offer-discount-stack");return e?JSON.parse(e):[]},getStackDiscountValidationData:function(e){if(i.isDiscountStacked()){const t=s.getStackDiscountFromStorage();let o=[],n=[];return t&&t.length&&t.forEach((t=>{s.isDiscountValid(e,t)?o.push(t):n.push(t)})),i.log("validDiscountCodes",o),i.log("invalidDiscountCodes:",n),{validDiscountCodes:o,invalidDiscountCodes:n}}},validateStackDiscount:function(e,t){if(i.isDiscountStacked()){const o=s.getStackDiscountValidationData(t),n=s.getDiscountFromStorage();o&&o.invalidDiscountCodes&&o.invalidDiscountCodes.length&&(o.invalidDiscountCodes.forEach((t=>{i.removeStackDiscount(t),s.deleteDiscountCode(e.myShopifyDomain,t.priceRuleId,t.discountCodeId),n&&t.code===n.code&&(i.log("Deleting discount from storage",t.code),localStorage.removeItem("lb-upsell-offer-discount"))})),localStorage.setItem("lb-upsell-offer-discount-stack",JSON.stringify(o.validDiscountCodes)))}},getDiscountMsg:function(e,t){const o=i.getCurrentLocale(),n=e.shopLocales&&e.shopLocales.length>1&&e.shopLocales.find((e=>e.primary));return n&&n.locale!==o&&t.translations&&t.translations[o]?t.translations[o].cartDiscountMsg:t.content.cartDiscountMsg},process:function(e,t){const o=i.getWidgetSetup(e,"product-page-cross-sell-embedded-widget"),n=i.getWidgetSetup(e,"product-page-addon-widget");let r=s.getDiscountFromStorage();if((o&&o.isEnabled||n&&n.isEnabled)&&r){let d=s.getDiscountMsg(e,r.code&&r.code.startsWith("ADD")?n:o),l=s.isDiscountValid(t,r),a=i.getCartForms();a.map((e=>e.getAttribute("id")));!function(e,t){if(e&&t){let t=i.getSetup();t&&t.customDiscountHelpSelector&&e?setTimeout((()=>{let o=document.querySelector(t.customDiscountHelpSelector);if(o){let n=document.querySelector(".lb-upsell-discount-help");n&&n.remove();let i=document.createElement("div");i.innerHTML=e,i.className="lb-upsell-discount-help",o.insertAdjacentElement(t.customDiscountHelpPosition,i)}}),500):setTimeout((()=>{let t=document.querySelector("ppcse-floting-toast");t&&(t.message=e,t.showFloatingToast())}),1e3)}}(d,l),s.addDiscountCodeToAllCartForms(l,a,r)}else i.log("Discounts wont be processed. ppcseWidget is not enabled / no discount in storage")},addDiscountCodeToAllCartForms:function(e,t,o){e&&t&&t.length&&t.forEach((e=>{i.log("Discount is valid, adding to cart form at page load");let t=` `;e.insertAdjacentHTML("beforeend",t)}))},removeDicountCodeFromAllCartForms:function(e){let t=document.querySelectorAll(`input[value="${e}"]`);t&&t.length&&t.forEach((e=>{i.log("Rmeoving discount elements"),e.remove()}))}}},895:(e,t,o)=>{const n=o(839);let i=e.exports={getOfferHistory:function(){let e=sessionStorage.getItem("lb-upsell-offer-history");return e?JSON.parse(e):void 0},pushEvent:function(e,t,o,r,s,d,l,a,c){if(n.isSnippetTesting())console.log("Metrics wont be pushed in snippet tesing mode.");else{let u={eventType:e,eventData:{isShopifyRecosOffer:l,account:{metricId:s.accountMetricId,id:s.myShopifyDomain},offer:{id:l?void 0:r.recordType,metricId:l?void 0:r.offerMetricId,widget:{id:d.recordType,metricId:d.widgetMetricId,isMultipleVariantsAdded:"widget#tpae"===d.recordType?!1!==d.isMultipleVariantsAdded:d.isMultipleVariantsAdded},details:{offerUniqueId:l?`shopify#${o}`:`shopify#${d.recordType}-${o}`,offeredProducts:t,leastPricedTriggerItem:a,addedVariants:d.isMultipleVariantsAdded&&c}}}};if(n.log("event:",u),"offer-viewed"===u.eventType){let e=sessionStorage.getItem("lb-upsell-offer-viewed");e=e?JSON.parse(e):{},e[u.eventData.offer.details.offerUniqueId]?n.log("Event offer-viewed already pushed"):(n.log("Pushing offer-viewed event"),e[u.eventData.offer.details.offerUniqueId]={offerId:l?`shopify#${o}`:u.eventData.offer.id},sessionStorage.setItem("lb-upsell-offer-viewed",JSON.stringify(e)),s.isViewMetricNotTracked?n.log("View tracking is disabled"):i.apiRequest("/metrics",u))}else if("offer-clicked"===u.eventType){let e=localStorage.getItem("lb-upsell-offer-clicked");e=e?JSON.parse(e):{};let t=u.eventData.offer.details.offeredProducts;if(e[u.eventData.offer.details.offerUniqueId])n.log("Event offer-clicked already pushed");else{n.log("Pushing offer-clicked event"),e[u.eventData.offer.details.offerUniqueId]={products:t,addedVariants:u.eventData.offer.details.addedVariants,leastPricedTriggerItem:u.eventData.offer.details.leastPricedTriggerItem,offerSettings:l?void 0:{id:u.eventData.offer.id,metricId:u.eventData.offer.metricId},widgetSettings:{id:u.eventData.offer.widget.id,metricId:u.eventData.offer.widget.metricId,isMultipleVariantsAdded:u.eventData.offer.widget.isMultipleVariantsAdded},isShopifyRecosOffer:l},i.apiRequest("/metrics",u),localStorage.setItem("lb-upsell-offer-clicked",JSON.stringify(e));let o={id:u.eventData.account.id,metricId:u.eventData.account.metricId,shopCurrencyCode:s&&s.shopCurrencyCode,shopifyCurrency:n.getPresentmentCurrency()};localStorage.setItem("lb-upsell-account-settings",JSON.stringify(o))}}}},apiRequest:function(e,t){let o=new XMLHttpRequest;o.open("POST",`${n.getHostName()}${e}`,!0),o.setRequestHeader("Content-Type","application/json; charset=UTF-8"),o.setRequestHeader("X-Metrics-Event-From","storefront"),o.send(JSON.stringify(t)),o.onload=function(){200===o.status&&n.log("Successfully processed event.")},o.onerror=function(){n.log("Error while processing metrics.")}},getFormattedOfferClicks:function(e){let t={};return Object.keys(e).forEach((o=>{if(e[o].offerSettings||e[o].isShopifyRecosOffer){let i=e[o].isShopifyRecosOffer?e[o].widgetSettings.id:e[o].offerSettings.id;t[i]?e[o].products&&t[i].products&&(t[i].products=n.arrayUnique(t[i].products.concat(e[o].products))):t[i]=e[o]}})),t},isConversionValid:function(e,t){return!t||(e.product_id!==t.product_id||(n.log("is 1+1 offer valid",e.quantity>t.quantity),e.quantity>t.quantity))},trackConversion:function(){let e=Shopify.checkout||{};n.log("checkout:",e);let t=localStorage.getItem("lb-upsell-offer-clicked");if(t=t?JSON.parse(t):void 0,e&&e.line_items&&e.line_items.length&&t&&Object.keys(t)&&Object.keys(t).length){let o=i.getFormattedOfferClicks(t),r=[];if(Object.keys(o).forEach((t=>{if(o[t].products&&o[t].products.length){let n=[],s=[],d=o[t];d.addedVariants&&d.addedVariants.length?d.addedVariants.forEach((n=>{let r=e.line_items.find((e=>`${e.variant_id}`==`${n.id}`));r&&i.isConversionValid(r,o[t].leastPricedTriggerItem)&&s.push(r)})):d.products.forEach((r=>{let s=e.line_items.find((e=>e.product_id===r));s&&i.isConversionValid(s,o[t].leastPricedTriggerItem)&&n.push(s)})),(n.length||s.length)&&r.push({id:d.isShopifyRecosOffer?void 0:d.offerSettings.id,metricId:d.isShopifyRecosOffer?void 0:d.offerSettings.metricId,widget:{id:d.widgetSettings.id,metricId:d.widgetSettings.metricId},details:{offeredProducts:d.products,converetedProducts:n,convertedVariants:s},isShopifyRecosOffer:d.isShopifyRecosOffer})}})),r&&r.length){let t=localStorage.getItem("lb-upsell-account-settings");t=t?JSON.parse(t):void 0;let o,s=localStorage.getItem("lb-upsell-offer-discount");s=s?JSON.parse(s):void 0,s&&s.code&&e.discount&&e.discount.applicable&&e.discount.code===s.code&&(o={code:s.code,priceRuleId:s.priceRuleId,discountCodeId:s.discountCodeId},localStorage.removeItem("lb-upsell-offer-discount"));let d={eventType:"offers-converted",eventData:{account:t,offers:r,order:{id:e.order_id,discount:e.discount},dicountToDelete:o}};n.log("event:",d),i.apiRequest("/metrics",d),localStorage.removeItem("lb-upsell-offer-clicked")}}}}},1:(e,t,o)=>{const n=o(721),i=o(839),r=o(895),s=o(570);let d,l,a;e.exports={ppaWidgetLib:function(){let e,t={};function o(e){i.ppaLog("---pushOfferViewedEvent---");let t=i.getSetup(),o=i.getWidgetSetup(t,"product-page-addon-widget"),n=e.offer.boughtTogether&&e.offer.boughtTogether.map((e=>e.id));r.pushEvent("offer-viewed",n,e.offer.for.id,l,t,o,!1)}function c(){i.ppaLog("---pushing OfferClickedEvent---");let e=d.boughtTogether&&d.boughtTogether.map((e=>e.id)),t=i.getSetup(),o=i.getWidgetSetup(t,"product-page-addon-widget");r.pushEvent("offer-clicked",e,d.for.id,l,t,o,!1)}function u(e,t,o){c();let n=document.querySelector("lb-upsell-product-page-addon");n&&n.handleAddToCartResponse(e.detail.products[0].id,"success"===t,e),i.triggerCustomEvent({widgetType:"product-page-addon-widget",currentAddToCartActionSetup:a,addToCartAction:e.detail.addToCartAction,discount:o})}function p(e){e.addEventListener("ppaModalAddToCartClicked",(function(e){if(e.detail&&e.detail.products&&e.detail.products.length){let t={items:e.detail.products.map((e=>({id:e.selectedVariantId,quantity:e.quantity})))};c(),i.addItemsToCart(t).then((e=>{i.triggerCustomEvent({widgetType:"product-page-addon-widget",isFromModal:!0});let t=document.querySelector("ppcse-modal");t&&t.addToCartOnSuccess()})).catch((e=>{i.ppaLog("Error - ppa widget modal add to cart")}))}})),e.addEventListener("ppaAjaxAddToCartClicked",(function(e){if(e.detail&&e.detail.products&&e.detail.products.length)if("add"===e.detail.addToCartAction){let t={items:e.detail.products.map((e=>({id:e.selectedVariantId,quantity:e.quantity})))};i.addItemsToCart(t,!0).then((t=>{let o=[];if("add"===e.detail.addToCartAction&&e.detail.totalWithoutDiscount>0){let t=i.getSetup();o.push(s.getDiscountCode(t.myShopifyDomain,e.detail.ajaxAddedItems,e.detail.discounts,e.detail.totalWithoutDiscount,void 0,"product-page-addon-widget",l&&l.recordType,void 0,d.for.id))}else o.push(Promise.resolve(!0));Promise.all(o).then((o=>{let n=e.detail.totalWithoutDiscount>0&&o&&o[0]?o[0]:void 0;if(n&&n.code){let t=i.getSetup();n.endsAt=new Date((new Date).getTime()+6e4*(t.customDiscountEndTimeInMins||30)).getTime(),s.saveDiscountToStorage(d.for.id,e.detail.ajaxAddedItems,n)}u(e,t,n)})).catch((o=>{i.ppaLog("Error while creating discount code:",o),u(e,t,void 0)}))})).catch((e=>{i.ppaLog("Error - ppa widget ajax add to cart")}))}else!function(e){i.getCart(window.location.hostname).then((t=>{let o={updates:{}};if("delete-all"===e.detail.addToCartAction)t.items&&t.items.length&&Object.keys(e.detail.addedVariants).forEach((n=>{let i=t.items.find((e=>`${e.id}`==`${n}`));i&&(o.updates[n]=Math.abs(e.detail.addedVariants[n].quantity-i.quantity))}));else{let n=0;if(t.items&&t.items.length){let o=t.items.find((t=>t.id===e.detail.products[0].selectedVariantId));o&&(n=e.detail.currentQty?Math.abs(e.detail.currentQty-o.quantity):o.quantity-1)}o={updates:{[e.detail.products[0].selectedVariantId]:n}}}i.updateCart(o).then((t=>{let o=document.querySelector("lb-upsell-product-page-addon");o&&o.handleAddToCartResponse(e.detail.products[0].id,"success"===t,e),i.triggerCustomEvent({widgetType:"product-page-addon-widget",currentAddToCartActionSetup:a,addToCartAction:e.detail.addToCartAction})}))}))}(e)})),e.addEventListener("ppaProductClicked",(function(e){e.detail&&c()}))}async function g(e,t,o=!1){if(i.isAddToCartClickForced=!0,i.isAddToCartClickForcedReset=!0,o)e&&(e.click(),s.handleDiscountAfterClick());else{c(),e&&(e.click(),s.handleDiscountAfterClick());let t=document.querySelector("lb-upsell-product-page-addon");t&&t.resetAddToCartAction()}}async function f(e,t,o,n,r,t){return new Promise(((t,c)=>{let u=[];if(o>0){let t=i.getSetup();0===l.minSelectable&&1===l.maxSelectable||1===l.minSelectable&&1===l.maxSelectable?u.push(s.getDiscountCode(t.myShopifyDomain,[e[0],r],n,o,e[0],"product-page-addon-widget",l&&l.recordType,!1,d.for.id)):u.push(s.getDiscountCode(t.myShopifyDomain,e,n,o,void 0,"product-page-addon-widget",l&&l.recordType,!1,d.for.id))}else u.push(Promise.resolve(!0));Promise.all(u).then((n=>{let r=o>0&&n&&n[0]?n[0]:void 0;if(r&&r.code){let t,o=i.getSetup();r.endsAt=new Date((new Date).getTime()+6e4*(o.customDiscountEndTimeInMins||30)).getTime();let n=i.getWidgetSetup(o,"product-page-addon-widget");n&&n.isDiscountForProductValidated&&(t=d.for.variants.map((e=>e.id))),s.saveDiscountToStorage(d.for.id,e,r,t)}i.triggerCustomEvent({widgetType:"product-page-addon-widget",currentAddToCartAction:a,discount:r}),t("success")})).catch((e=>{i.ppaLog("Error while creating discount code.",e),i.triggerCustomEvent({widgetType:"product-page-addon-widget",currentAddToCartAction:a,discount:void 0}),c("Falied")}))}))}function m(e){return new Promise(((t,n)=>{let r=function(){let e=[],t=document.querySelectorAll("form");if(t)for(let o=0;o-1)&&e.push(t[o]);return e&&e.length?e[0]:void 0}(),s=document.createElement("lb-upsell-product-page-addon");if(r){r.insertAdjacentElement("afterend",s);let n=document.querySelector("lb-upsell-product-page-addon");n?(n.widget=e.widget,n.offer=e.offer,n.widget.addToCartAction="ajax",a="ajax",i.ppaLog("Widget successfully added to cart form. Trigger changed to ajax"),p(n),o(e),t(!0)):(i.ppaLog("ppcseWidget not found"),t(!1))}else i.debugLog("Addons widget - Could not find cart add form"),i.ppaLog("Could not find cart add form"),t(!1)}))}function h(){return window.innerWidth<=768}function w(e,t,r,s){i.removeExistingWidget("lb-upsell-product-page-addon");let d=n.getAddToCartBtnCSS(".ppa-add-to-cart-btn");d&&i.appendCustomTextCssToHead(d,"lb-upsell-ppa-atc-css");let l=h()?t.position.mobile.selector:t.position.desktop.selector,c=h()?t.position.mobile.insertPosition:t.position.desktop.insertPosition;r&&s&&(i.ppaLog("Using custom positioning"),l=r,c=s),i.ppaLog("----------Positioning widget----------"),"addToCartBtn"===l&&"beforebegin"===c?function(e){return new Promise(((t,r)=>{i.ppaLog("Adding widget to addWidgetToCartFormSubmitBtn");let s=n.getProductCartAddForms(),d=document.createElement("lb-upsell-product-page-addon");if(s&&s.length){let n=s[0].querySelectorAll("button,input");for(let e=0;e{t||m(e).then((e=>{e||(i.debugLog("Addons widget - Cannot default position widget, check selectors"),i.ppaLog("Cannot default position widget check selectors"))}))})):function(e,t,n){return new Promise(((r,s)=>{i.ppaLog("added widget to custom selector");let d=document.querySelector(e);if(d){d.insertAdjacentHTML(t," \n \n");let s=document.querySelector("lb-upsell-product-page-addon");s?(s.widget=n.widget,s.offer=n.offer,a=n.widget.addToCartAction,i.ppaLog(`Widget successfully added to selector , ${e}`),p(s),o(n),r(!0)):(i.ppaLog("ppcseWidget not found"),r(!1))}else i.ppaLog(`Could not find selector, ${e}`),r(!1)}))}(l,c,e).then((e=>{e||(i.debugLog("Addons widget - cannot find CSS ,check selectors"),i.ppaLog("Check custom CSS selector."))}))}return t.handleAddToCart=function(e){let t=document.querySelector("lb-upsell-product-page-addon");t?t.getAddedItems().then((t=>{i.ppaLog("Result",t),t.addedItems&&t.addedItems.length&&"trigger"===a?function(e,t,o,n,r){let s={items:e.map((e=>({id:e.selectedVariantId,quantity:e.quantity||1})))},d=[i.addItemsToCart(s,!0,!0),f(e,0,o,n,r)];Promise.all(d).then((e=>{g(t),i.log("ATC and discount promise complete.",e)})).catch((e=>{i.ppaLog("Error - ppa widget addAllItemsToCart add to cart",e),g(t,0,!0),i.triggerCustomEvent({widgetType:"product-page-addon-widget",currentAddToCartAction:a,discount:void 0})}))}(t.addedItems,e,t.totalWithoutDiscount,t.discounts,t.forProduct):(i.isAddToCartClickForced=!0,i.isAddToCartClickForcedReset=!0,e&&e.click())})):(i.isAddToCartClickForced=!0,i.isAddToCartClickForcedReset=!0,e&&e.click())},t.render=function(t,o,r,s){e=t;const a=i.getSetup();if(n.isProductPage()||o){i.ppaLog("product page found");const e=a.widgets.find((e=>"product-page-addon-widget"===e.type));if(e&&e.isEnabled){const c=o||n.getProductHandle();i.getProduct(c).then((async o=>{if(o.available)if(a.offers&&a.offers.length){const u=await i.getOffer(a,o,"product-addons");i.ppaLog("Best offer :",u),u&&(i.debugLog(`Initializing offer, ${u.name}`),n.getFormattedWidgetInput(e,u,c,o.id,t).then((t=>{d=t.offer,l=u,i.ppaLog("Final offer input to wiget",t.offer),i.ppaLog("wiget settings",t.widget),i.ppaLog(JSON.stringify(t)),i.ppaLog("---------------"),t.offer&&t.offer.boughtTogether&&t.offer.boughtTogether.length?(i.ppaLog("---------------"),a.version>=18&&window.lbUpsellComponents&&window.lbUpsellComponents.registerAddToCartListeners(),w(t,e,r,s)):(i.ppaLog("Not enough products to position widgets"),i.ppaLog("---------------"))})))}else i.ppaLog("No offer setup found"),e.useShopifyProductRecommendations&&n.showShopifyProductRecommendations(o,e).then((t=>{d=t.offer,i.ppaLog("Final offer input to wiget",t.offer),i.ppaLog("wiget settings",t.widget),i.ppaLog(JSON.stringify(t)),i.ppaLog("---------------"),a.version>=18&&window.lbUpsellComponents&&window.lbUpsellComponents.registerAddToCartListeners(),w(t,e,r,s)}));else i.ppaLog("For product is not available.")})).catch((e=>{i.ppaLog("Error while querying product from AJAX API",e)}))}}},t}}},907:(e,t,o)=>{const n=o(895),i=o(839),r=o(570),s=o(721);e.exports={ppcseWidgetLib:function(){let e,t,o,d,l,a,c={};function u(){let e=document.querySelector("lb-product-page-cross-sell-ew");e&&e.addToCartOnSuccess("success")}function p(o,r,a){i.log("Successfully added items to cart.");let c=t.boughtTogether&&t.boughtTogether.map((e=>e.id));switch(n.pushEvent("offer-clicked",c,t.for.id,d,e,o,l),i.triggerCustomEvent({widgetType:"product-page-cross-sell-embedded-widget",discount:r,isFromModal:a}),o.addToCartAction){case"stay":u();break;case"redirect":setTimeout((()=>{let e=i.getRootRoute();window.location=e&&"/"!==e?`https://${window.location.hostname}${e}cart`:`https://${window.location.hostname}/cart`}),1e3);break;case"reload":u(),setTimeout((()=>{window.location.reload()}),1500);break;case"autoAddToCart":{let e=s.isAutoAddToCartValid(t.for);e?(e.click(),u()):(u(),setTimeout((()=>{window.location.reload()}),1500));break}case"redirect_checkout":{let e=i.getRootRoute();window.location.href=e&&"/"!==e?`${e}cart/checkout${r?`?discount=${r.code}`:""}`:"/cart/checkout"+(r?`?discount=${r.code}`:"");break}}}function g(n,d,l,a,c){let u={items:n.map((e=>{if(t.for.id!==e.id||!s.isAutoAddToCartValid(t.for))return{id:e.selectedVariantId,quantity:d?Number(d):1}})).filter((e=>e))};i.addItemsToCart(u,!0).then((()=>{let i=l>0&&a&&a[0]?a[0]:void 0;i&&i.code&&(i.endsAt=new Date((new Date).getTime()+6e4*(e.customDiscountEndTimeInMins||30)).getTime(),r.saveDiscountToStorage(t.for.id,n,i)),p(o,i,c)})).catch((e=>{i.log("Error while adding items to cart",e),p(o,void 0,c)}))}function f(s){s.addEventListener("addToCartClicked",(function(o){o.detail&&o.detail.products&&o.detail.products.length&&(i.log("event.detail:",o.detail),function(o,n,s,l,a,c,u){let p=[];s>0?(a&&window.isDynamicCheapProduct&&(a=o.reduce(((e,t)=>t.selectedVariantPrice{g(o,n,s,e,u)})).catch((e=>{i.log("Error while creatin g discount code.",e),g(o,n,s,void 0,u)}))}(o.detail.products,o.detail.quantity,o.detail.totalWithoutDiscount,o.detail.total,o.detail.cheapestProduct,o.detail.discounts,o.detail.isFromModal))})),s.addEventListener("productClicked",(function(i){if(i.detail){let i=t.boughtTogether&&t.boughtTogether.map((e=>e.id));n.pushEvent("offer-clicked",i,t.for.id,d,e,o,l)}}))}function m(){return window.innerWidth<=768}function h(t){return new Promise(((r,s)=>{let a=function(){let e=[],t=document.querySelectorAll("form");if(t)for(let o=0;o-1)&&e.push(t[o]);let o=window.Shopify&&window.Shopify.theme&&window.Shopify.theme.name&&"Dawn"===window.Shopify.theme.name,n=e&&e.length?e[0]:void 0;return o&&e&&e.length>0&&(n=e[1]),n}(),c=document.createElement("lb-product-page-cross-sell-ew");if(a){a.insertAdjacentElement("afterend",c);let s=document.querySelector("lb-product-page-cross-sell-ew");if(s){s.widget=t.widget,s.offer=t.offer,f(s);let a=t.offer.boughtTogether&&t.offer.boughtTogether.map((e=>e.id));n.pushEvent("offer-viewed",a,t.offer.for.id,d,e,o,l),i.log("Widget successfully added to cart form"),r(!0)}else i.log("ppcseWidget not found"),r(!1)}else i.log("Could not find cart add form"),i.debugLog("FBT widget - Could not find cart add form."),r(!1)}))}function w(t,r,s){return new Promise(((a,c)=>{let u=document.querySelector(t);if(u){u.insertAdjacentHTML(r," \n \n");let c=document.querySelector("lb-product-page-cross-sell-ew");if(c){c.widget=s.widget,c.offer=s.offer,f(c);let r=s.offer.boughtTogether&&s.offer.boughtTogether.map((e=>e.id));n.pushEvent("offer-viewed",r,s.offer.for.id,d,e,o,l),i.log(`Widget successfully added to selector , ${t}`),a(!0)}else i.log("ppcseWidget not found"),a(!1)}else i.log(`Could not find selector, ${t}`),a(!1)}))}function b(t,o){if(i.removeExistingWidget("lb-product-page-cross-sell-ew"),e.version>=2){let e=s.getAddToCartBtnCSS(".ppcse-tot-btn");e&&i.appendCustomTextCssToHead(e,"lb-upsell-ppcse-atc-css")}const n=m()?o.position.mobile.selector:o.position.desktop.selector,r=m()?o.position.mobile.insertPosition:o.position.desktop.insertPosition;i.log("----------Positioning widget----------"),e.version>=2?".product-form"===n&&"afterend"===r?h(t).then((e=>{e||w(n,r,t).then((e=>{e||w(".product-single","afterend").then((e=>{e||(i.debugLog("FBT widget - Could not add widget to .product-single in version 2 with default positioning, no more retries"),i.log("Could not add widget to .product-single in version 2 with default positioning, no more retries"))}))}))})):w(n,r,t).then((e=>{e||i.log("Check custom CSS selector.")})):".product-single"===n&&"afterend"===r?w(n,r,t).then((e=>{e||h(t).then((e=>{e||i.log("Could not add widget to form in version 1 with default positioning, no more retries")}))})):w(n,r,t).then((e=>{e||i.log("Check custom CSS selector.")})),i.log("widgetInput:",JSON.stringify(t))}function y(e){s.showShopifyProductRecommendations(e,o,a).then((e=>{l=!0,t=e.offer,i.log("Final offer input to wiget",e.offer),i.log("wiget settings",e.widget),i.log("---------------"),b(e,o)}))}return c.render=function(n,r,l){if(e=n,a=r,s.isProductPage()||l){i.log("product page found");const n=e.widgets.find((e=>"product-page-cross-sell-embedded-widget"===e.type));if(n&&n.isEnabled){o=n;const a=l||s.getProductHandle();i.getProduct(a).then((async o=>{if(o.available)if(e.offers&&e.offers.length){const l=await i.getOffer(e,o,"frequently-bought-bundle");i.log("Best offer :",l),l?(i.debugLog(`Initializing offer, ${l.name}`),s.getFormattedWidgetInput(n,l,a,o.id,r,o).then((e=>{t=e.offer,d=l,e.offer&&e.offer.boughtTogether&&e.offer.boughtTogether.length?(i.log("Final offer input to wiget",e.offer),i.log("wiget settings",e.widget),i.log("---------------"),b(e,n)):(i.log("Not enough products to position widgets"),i.log("---------------"))}))):(i.log("------No matching offer found.----------"),n.useShopifyProductRecommendations&&y(o))}else i.log("No offer setup found"),n.useShopifyProductRecommendations&&y(o);else i.log("For product is not available.")})).catch((e=>{i.log("Error while querying product from AJAX API",e)}))}}},c}}},721:(e,t,o)=>{const n=o(839),i=o(570);let r=e.exports={isProductPage:function(){return-1!==window.location.pathname.indexOf("/products/")},getProductHandle:function(){const e=window.location.pathname.split("/");return e&&e.length&&e[e.length-(window.location.pathname.endsWith("/")?2:1)]},getProducts:function(e,t){return new Promise(((o,i)=>{let r=[n.getProduct(e)];t.boughtTogether.offeredProducts.products.forEach((e=>{r.push(n.getProduct(e.handle))})),Promise.all(r).then((e=>{e&&e.length&&(e=e.filter((e=>e))),o(e)}))}))},filterProducts:function(e,t){const o=!!t&&("product-page-addon-widget"===t.type&&t.isSoldOutProductsShown);return e.filter((e=>(e.available||o)&&n.isImgAvailable(e))).map((e=>(e.variants&&e.variants.length&&(e.variants=e.variants.filter((e=>e.available||o))),e)))},isAutoAddToCartValid:function(e){let t=n.getWidgetSetup(n.getSetup(),"product-page-cross-sell-embedded-widget");return"autoAddToCart"===t.addToCartAction&&(e.variants&&1===e.variants.length||!e.variants)&&document.querySelector(t.addToCartSelector)},getProductCartAddForms:function(){let e=[],t=document.querySelectorAll("form");if(t)for(let o=0;o-1)){let n=t[o].querySelectorAll("button,input");for(let i=0;i{let c=n.getStyle(e[r],s);"background-color"===s&&(d=c),"border-color"===s&&(a=c),l&&l.version>=4&&"color"===s&&i.includes(c)&&i.includes(d)&&(c=a),t+=`${s}:${c};`,"background-color"===s&&document.documentElement.style.setProperty("--lb-ppa-spc-cta-bg",`${c}`),"color"===s&&(o=`${c};`,document.documentElement.style.setProperty("--lb-ppa-spc-cta-btn-color",`${c}`)),"border-color"===s&&document.documentElement.style.setProperty("--lb-ppa-spc-cta-border",`${c}`)}));break}}return t.length?`${e}{\n${t}\n}\n.lb-upsell-tot-btn{\n${t}}\n.ppcse-spinner circle{\nstroke: ${o};\n}`:void 0},getFormattedWidgetInput:function(e,t,o,s,d,l){return new Promise(((a,c)=>{const u=n.getSetup();let p;p="product-page-addon-widget"===e.type?!i.isWidgetDiscountValid(d,"FUNDLL")&&!i.isWidgetDiscountValid(d,"BUNDLL")&&i.isDiscountShown(s,d,"ADDDLL")&&"view"!==e.addToCartAction:!i.isWidgetDiscountValid(d,"FUNDLL")&&!i.isWidgetDiscountValid(d,"ADDDLL")&&i.isDiscountShown(s,d,"BUNDLL"),n.isDiscountStacked()&&(p=!0);let g={boughtTogether:[],discounts:p&&t.discounts&&t.discounts.isEnabled&&t.discounts,overrideWidgeTitle:t.overrideWidgeTitle},f={styles:e.styles,content:e.content,isQuantityPickerEnabled:e.isQuantityPickerEnabled,isQtyPickerHidden:e.isQtyPickerHidden,discountCondition:e.discountCondition,imageResolution:e.imageResolution,isMultipleVariantsAdded:e.isMultipleVariantsAdded,metadata:{shopCurrencyFormat:u&&u.shopEmailCurrencyFormat?u.shopEmailCurrencyFormat:u.shopCurrencyFormat,isAmountNoDecimals:u&&u.isAmountNoDecimals,shopMoneyInEmailsFormat:u&&u.shopMoneyInEmailsFormat,shopCurrencyCode:u&&u.shopCurrencyCode,presentmentCurrency:void 0,isUnitPriceShown:u&&u.isUnitPriceShown,setupVersion:u.version,variantsGroupSeperator:u.variantsGroupSeperator}},m=n.getTranslations(u,e,t,g,f);g=m.offer,f=m.widget;let h=[];t.boughtTogether.shopifyProductRecommendations&&t.boughtTogether.shopifyProductRecommendations.isEnabled?h.push(r.getShopifyProductRecomendation(l.id,t.boughtTogether.shopifyProductRecommendations.limit)):h.push(r.getProducts(o,t)),Promise.all(h).then((i=>{let s;n.ppaLog("--------Processing best offer --------"),t.boughtTogether.shopifyProductRecommendations&&t.boughtTogether.shopifyProductRecommendations.isEnabled?(s=i&&i[0].products&&i[0].products.length?[l,...i[0].products]:[l],s.forEach((e=>{e.productId=e.id}))):s=i&&i[0].length?i[0]:[],n.ppaLog("Reference products fetch successfull",s);let d=n.filterProducts(s,e);n.ppaLog("Filtered Products based on product/variant availablity & image:",d);let c=d.find((e=>(e.handle||"").toLowerCase()===(decodeURI(o)||"").toLowerCase()));c=JSON.parse(JSON.stringify(c)),c.isForProduct=!0;let u=t.boughtTogether.shopifyProductRecommendations&&t.boughtTogether.shopifyProductRecommendations.isEnabled?JSON.parse(JSON.stringify(i[0].products)):JSON.parse(JSON.stringify(t.boughtTogether.offeredProducts.products));u=n.getBoughtProductsRandomSortOrder(u,t.isSortedRandomly),u.sort(((e,t)=>e.sortNo-t.sortNo)),u=n.mapAvailableProducts(u,d,t.for.selectorType,c,void 0,void 0),u=n.removeExtraItems(u,e.maxItemsInOffer),g.boughtTogether=u,f.metadata.presentmentCurrency=n.getPresentmentCurrency(),"product-page-addon-widget"===e.type?(f.addToCartAction=e.addToCartAction,f.layoutStyle=e.layoutStyle||"list",f.addActionStyle=e.addActionStyle||"button",f.productClickActionStyle=e.productClickActionStyle||"popup","trigger"!==f.addToCartAction||"checkbox"!==e.addActionStyle&&"checkbox-left"!==e.addActionStyle||!(0===t.minSelectable&&1===t.maxSelectable||1===t.minSelectable&&1===t.maxSelectable)||(f.addActionStyle="checkbox-left"===f.addActionStyle?"radio-left":"radio"),"view"===f.addToCartAction&&(f.addActionStyle="button",f.productClickActionStyle="redirect_new_tab")):f.addToCartAction=r.isAutoAddToCartValid(c,e)&&e.addToCartAction,"product-page-cross-sell-embedded-widget"===e.type&&(f.productClickActionStyle=e.productClickActionStyle||"popup",f.isProductDetailsCollpased=e.isProductDetailsCollpased,f.isImagesNotFiltered=e.isImagesNotFiltered,f.layoutStyle=e.layoutStyle||"classic"),a({widget:f,offer:{for:c,boughtTogether:g.boughtTogether,minSelectable:("radio"===f.addActionStyle||"radio-left"===f.addActionStyle)&&t.minSelectable,maxSelectable:("radio"===f.addActionStyle||"radio-left"===f.addActionStyle)&&t.maxSelectable,discounts:g.discounts,overrideWidgeTitle:g.overrideWidgeTitle}})})).catch((e=>{n.ppaLog("Error while getProducts",e),c(e)}))}))},getShopifyProductRecomendation:function(e,t){return new Promise(((o,i)=>{let r;var s=new XMLHttpRequest;let d=n.getRootRoute();r=d&&"/"!==d?`https://${window.location.hostname}${d}recommendations/products.json?product_id=${e}&limit=${t}`:`https://${window.location.hostname}/recommendations/products.json?product_id=${e}&limit=${t}`,s.open("GET",r,!0),s.setRequestHeader("Content-Type","application/json; charset=UTF-8"),s.setRequestHeader("Access-Control-Allow-Origin","*"),s.send(),s.onload=()=>{200===s.status&&o(JSON.parse(s.responseText))},s.onerror=()=>{i("Error while getting product recommendations"+e)}}))},showShopifyProductRecommendations:function(e,t,o){return new Promise(((s,d)=>{let l=n.getSetup();if(n.log("Fetching productRecommendations"),e&&n.isImgAvailable(e)){let d=Number(t.maxItemsInOffer)>0?t.maxItemsInOffer:2;r.getShopifyProductRecomendation(e.id,d).then((d=>{if(n.log("ProductRecommendations result:",d),d&&d.products&&d.products.length){let a=n.filterProducts([e],t)[0],c=n.filterProducts(d.products,t);if(a&&c.length){let e={for:a,boughtTogether:c,discounts:void 0},d={styles:t.styles,content:t.content,metadata:{shopCurrencyFormat:l&&l.shopEmailCurrencyFormat?l.shopEmailCurrencyFormat:l.shopCurrencyFormat,isAmountNoDecimals:l&&l.isAmountNoDecimals,shopMoneyInEmailsFormat:l&&l.shopMoneyInEmailsFormat,shopCurrencyCode:l&&l.shopCurrencyCode,presentmentCurrency:n.getPresentmentCurrency(),isUnitPriceShown:l&&l.isUnitPriceShown,setupVersion:l.version,variantsGroupSeperator:l.variantsGroupSeperator}};if(l.shopLocales&&l.shopLocales.length>1){n.log("Checking shoplocale");const e=n.getCurrentLocale(),o=l.shopLocales.find((e=>e.primary));o&&o.locale!==e&&t.translations&&t.translations[e]&&(n.log("Replacing primaery locale"),d.content=t.translations[e])}let u,p=e.for;p=JSON.parse(JSON.stringify(p)),p.isForProduct=!0,"product-page-addon-widget"===t.type?(d.addToCartAction=t.addToCartAction,d.layoutStyle=t.layoutStyle||"list",d.addActionStyle=t.addActionStyle||"button",d.productClickActionStyle=t.productClickActionStyle||"popup",u=!i.isWidgetDiscountValid(o,"FUNDLL")&&!i.isWidgetDiscountValid(o,"BUNDLL")&&i.isDiscountShown(p.id,o,"ADDDLL")):(d.addToCartAction=r.isAutoAddToCartValid(p,t)&&t.addToCartAction,d.productClickActionStyle=t.productClickActionStyle||"popup",d.isProductDetailsCollpased=t.isProductDetailsCollpased,d.isImagesNotFiltered=t.isImagesNotFiltered,u=!i.isWidgetDiscountValid(o,"FUNDLL")&&!i.isWidgetDiscountValid(o,"ADDDLL")&&i.isDiscountShown(p.id,o,"BUNDLL")),n.isDiscountStacked()&&(u=!0),u&&"product-page-cross-sell-embedded-widget"===t.type&&t.useShopifyProductRecommendations&&t.recommendationDiscount&&t.recommendationDiscount.isEnabled&&(e.discounts={...t.recommendationDiscount,isAutoRecommendationDiscount:!0}),s({offer:{for:p,boughtTogether:e.boughtTogether,discounts:e.discounts},widget:d})}}}))}else n.log("For product image not found, so no offer will be rendered")}))}}},931:(e,t,o)=>{const n=o(839),i=o(150);let r=e.exports={getLocalCache:function(){let e=localStorage.getItem("lb-upsell-setup"),t=localStorage.getItem("lb-upsell-setupFetchedAt");return e&&t&&Number(t)>(new Date).getTime()-72e5?JSON.parse(e):void 0},setLocalCache:async function(e){localStorage.setItem("lb-upsell-setup",JSON.stringify(e)),localStorage.setItem("lb-upsell-setupFetchedAt",(new Date).getTime())},clearLocalCache:function(){localStorage.removeItem("lb-upsell-setup"),localStorage.removeItem("lb-upsell-setupFetchedAt")},fetchObject:function(e,t,o=[],s=void 0){return new Promise(((d,l)=>{let a={cursor:s||null};var c=new XMLHttpRequest;c.open("POST",`https://${window.location.hostname}/api/${i.API_VERSION}/graphql.json`,!0),c.setRequestHeader("Content-Type","application/json; charset=UTF-8"),c.setRequestHeader("X-Shopify-Storefront-Access-Token",e),c.setRequestHeader("Access-Control-Allow-Origin","*"),c.send(JSON.stringify({query:t.queryString,variables:a})),c.onload=()=>{if(200===c.status){let i=JSON.parse(c.responseText);n.log("fetch from sf api ==>",i),i&&i.data&&i.data.metaobjects&&i.data.metaobjects.nodes?(i.data.metaobjects.nodes.length||d([]),t.isOffersFetch||d(i.data.metaobjects.nodes),i.data.metaobjects.pageInfo&&i.data.metaobjects.pageInfo.hasNextPage?r.fetchObject(e,t,i.data.metaobjects.nodes,i.data.metaobjects.pageInfo.endCursor).then((e=>{o=[...o,...e],n.log("Returning paginated offer",o),d(o)})).catch((e=>{n.log("Error while fetching paginated Offers!",e)})):d([...o,...i.data.metaobjects.nodes])):l(!1)}else n.log("Error while fetch setup from the SF api."),l("Error while fetch setup from the SF api.")},c.onerror=()=>{n.log("Error while fetch setup from the SF api."),l("Error while fetch setup from the SF api. ")}}))},isSetupCachedInClientSide:e=>!(e.createdAt>=(new Date).valueOf()-6048e5)&&(!e.lastAdminActiveAt||e.lastAdminActiveAt<(new Date).valueOf()-72e5),getSFSetup:function(e,t,o=void 0){let i=[{queryString:'{\n metaobjects(type: "$app:selleasy-setup", first: 1) {\n nodes {\n field(key: "selleasy-setup") {\n value\n key\n }\n id\n handle\n }\n }\n }',isOffersFetch:!1}];void 0!==o&&i.push({queryString:'query getMetaObjects($cursor: String) {\n metaobjects(type: "$app:selleasy-offer", first: 250, after: $cursor) {\n nodes {\n field(key: "selleasy-offer") {\n value\n key\n }\n id\n handle\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n }',isOffersFetch:!0});let s=i.map((e=>r.fetchObject(t,e)));Promise.all(s).then((t=>{if(t&&t.length){let n=t[0]&&t[0][0];if(n){let i=JSON.parse(n&&n.field&&n.field.value||"{}");i.isStorefrontApiEnabled?(i.offers=t[1]&&t[1].map((e=>e&&e.handle&&e.handle.includes("selleasy-offer")&&e.field&&e.field.value&&JSON.parse(e.field.value||"{}")))||[],void 0!==o&&o("setup",i),r.isSetupCachedInClientSide(i)||r.clearLocalCache()):void 0!==o&&r.fetchSetup(e,o,!0)}else void 0!==o&&r.fetchSetup(e,o,!0)}else void 0!==o?r.fetchSetup(e,o,!0):r.validateSetup(e,!0),n.log("SF api failed!")})).catch((t=>{n.log("Error while resolving get setup proimses: fallback to Api fetch",t),void 0!==o?r.fetchSetup(e,o,!0):r.validateSetup(e,!0)}))},fetchSetup:function(e,t,o=!1){if(window&&window.lbupsellToken&&!o)n.log("Token",window.lbupsellToken),r.getSFSetup(e,window.lbupsellToken,t);else{let o=`${n.getHostName()}/setup?myShopifyDomain=${e}`;var i=new XMLHttpRequest;i.open("GET",o,!0),i.setRequestHeader("Content-Type","application/json; charset=UTF-8"),i.send(),i.onload=function(){if(200===i.status){let e=JSON.parse(i.responseText);n.log("Setup fetch successfull",e),t("setup",e),e.isSetupCachedInClientSide&&r.setLocalCache(e)}},i.onerror=function(){n.log("Failed while fetching setup")}}},validateSetup:async function(e,t=!1){if(window&&window.lbupsellToken&&!t)n.log("Token",window.lbupsellToken),r.getSFSetup(e,window.lbupsellToken,void 0);else{var o=new XMLHttpRequest;o.open("GET",`${n.getHostName()}/setupValidate?myShopifyDomain=${e}`,!0),o.setRequestHeader("Content-Type","application/json; charset=UTF-8"),o.send(),o.onload=function(){if(200===o.status){let e=JSON.parse(o.responseText);n.log("Setup validation response !!!",e),e&&!e.isSetupCachedInClientSide&&(n.log("Clearing cache !!!",e.isSetupCachedInClientSide),r.clearLocalCache())}},o.onerror=function(){n.log("Failed while fetching setup")}}},getSetup:function(e,t){let o=r.getLocalCache();o?(t("setup",o),n.log("Using local cache setup !!"),r.validateSetup(e)):(n.log("Fetchig setup !!"),r.fetchSetup(e,t))}}},839:(e,t,o)=>{const n=o(150),i=n.HOST_NAME,r="true"===n.IS_LOGS_REQUIRED;let s,d=e.exports={isCheckoutClickForced:!1,isAddToCartClickForced:!1,isAddToCartClickForcedReset:!1,isPrerenderingDisabled:!1,log:function(e,t){r&&console.log(e,t||"")},upsellFunnelLog:function(e,t){r&&console.log("%s",e,t||"")},ppaLog:function(e,t){r&&console.log("%s",e,t||"")},debugLog:function(e,t){localStorage.getItem("selleasyDebugLogsEnabled")&&console.log(e,t||"")},getCookieValue:function(e){for(var t=document.cookie.split(";"),o=0;o(e.available||d.debugLog(` ${e.title}, product is out of stock.`),d.isImgAvailable(e)||d.debugLog(` ${e.title}, product image not available.`),(e.available||o)&&d.isImgAvailable(e)))).map((e=>(e.variants&&e.variants.length&&(e.variants=e.variants.filter((t=>(t.available||d.debugLog(`${e.title} - ${t.title}, product variant not available.`),t.available||o)))),e)))},getTranslations:function(e,t,o,n,i){if(e.shopLocales&&e.shopLocales.length>1){d.log("Checking shoplocale");const r=d.getCurrentLocale(),s=e.shopLocales.find((e=>e.primary));s&&s.locale!==r&&(d.log("Replacing primaery locale"),t.translations&&t.translations[r]&&(i.content={...i.content,...t.translations[r]}),o.translations&&o.translations[r]&&(o.translations[r].overrideWidgeTitle&&(n.overrideWidgeTitle=o.translations[r].overrideWidgeTitle),n.discounts&&n.discounts.description&&o.translations[r].description&&(n.discounts.description=o.translations[r].description)),d.log("formattedOffer",n))}return{offer:n,widget:i}},getBoughtProductsRandomSortOrder:function(e,t){if(t){let t=d.getRandomSortOrder(e.length);return d.ppaLog("Random Sort Order:",t),d.ppaLog("True Sort Order",e.map((e=>e.sortNo))),e.map(((e,o)=>(e.sortNo=t[o],e)))}return e},mapAvailableProducts:function(e,t,o,n,i,r){return e.map((s=>{let l=t.find((e=>e.id==s.productId));const a=l&&("tags"===o||"all"===o||"products"===o&&1!==e.length)&&(r?r.some((e=>e.id===l.id)):n&&n.id===l.id);if(a&&d.debugLog(`${l.title}, product excluded because - ${r?"item already in cart":`selectorType = ${o}`}.`),l&&s.limitVariants&&s.limitVariants.length&&s.limitVariants.length<=l.variants.length){let e=l.variants.filter((e=>!s.limitVariants.some((t=>t.id==e.id))));console.log(`${l.title} - ${e&&e.length?e.map((e=>e.title)):""}, variants are limited`),l.variants=l.variants.filter((e=>s.limitVariants.some((t=>t.id==e.id))))}return l&&i&&(l.discount=s.discount),!a&&l})).filter((e=>e&&e.variants&&e.variants.length))},removeExtraItems:function(e,t){return Number(t)>0&&e.length>t?(d.ppaLog("Removed extra items (maxItemsInOffer) in boughttogether",e),e.slice(0,t)):e},getOffer:async function(e,t,o){if(d.log("--------Finding best offer------"),!t||"frequently-bought-bundle"===o&&!d.isImgAvailable(t))d.log("For product image not found, so no offer will be rendered");else{let n=[];if(e.offers&&e.offers.length){let i=JSON.parse(JSON.stringify(e.offers.filter((e=>!e.version||e.version>=2&&"product-page"===e.placementPage&&e.upsellType===o))));return i=d.sortByPriorityAndLatestOffer(i),i.forEach((e=>{if("products"===e.for.selectorType){e.for.products.some((e=>e.handle===decodeURI(t.handle)||`${t.id}`===e.productId))&&n.push(e)}else if("tags"===e.for.selectorType&&t.tags&&t.tags.length){e.for.products.some((e=>t.tags.some((t=>(t||"").toLowerCase()===(e.name||"").toLowerCase()))))&&n.push(e)}else"all"===e.for.selectorType&&n.push(e)})),d.log("applicableOffers:",n),n.length?n[0]:void 0}}},getCartForms:function(){let e=[],t=document.querySelectorAll("form");if(t)for(let o=0;o-1)&&e.push(t[o]);return e},getBtnCSS:function(e,t=!1){let o="",n="",i=["#fff","#ffffff","white","rgb(255, 255, 255)","rgba(255, 255, 255, 1)","rgba(0, 0, 0, 0)","transparent"];return["color","background","background-color","font-size","font-family","letter-spacing","font-weight","text-transform"].forEach((r=>{!t&&"background-color"===r&&i.includes(d.getStyle(e,r))?(o+="background-color: green;",o+="color: white;"):o+=`${r}:${d.getStyle(e,r)};`,"color"===r&&(n=`${d.getStyle(e,r)};`)})),o.length?{fetchedCSS:o,addToCartSpinnerStrokeColor:n}:void 0},setBtnCSS:function(e,t=!1){if(s&&s.version>=4){let o=d.getBtnCSS(e,t);if(o){let e=t?`.lb-tpae-confirm-button{\n${o.fetchedCSS}\n}\n.tpae-order-spinner circle{\nstroke: ${o.addToCartSpinnerStrokeColor}\n}`:`.lb-upsell-modal-product-primary{\n${o.fetchedCSS}\n}\n.lb-upsell-primary-spinner circle{\nstroke: ${o.addToCartSpinnerStrokeColor}\n}\n .lb-addon-popup-continue-btn{\n${o.fetchedCSS}\n}.lb-addon-popup-continue-spinner circle{\nstroke: ${o.addToCartSpinnerStrokeColor}\n}`;d.appendCustomTextCssToHead(e,"lb-upsell-checkout-css")}}},addCheckoutListenerToElements:function(e,t,o,n){for(let i=0;i=18?"lb-upsell-default-checkout-listener":"listener",o,e),0===n.length){let n=e.querySelectorAll("button[name='checkout'], input[name='checkout']");if(n&&n.length)d.addCheckoutListenerToElements(n,s.version>=18?"lb-upsell-default-checkout-listener":"listener",o,e);else{let n=document.querySelectorAll("button[name='checkout'], input[name='checkout']"),i=[];for(let e=0;e=18?"lb-upsell-default-checkout-listener":"lb-upsell-listener")&&t.some((t=>t===n[e].getAttribute("form")))&&i.push(n[e]);i&&i.length&&d.addCheckoutListenerToElements(i,s.version>=18?"lb-upsell-default-checkout-listener":"lb-upsell-listener",o,e)}}d.log("Added cart submit listeners.")},getFormattedProductHandle:function(e){const t=e.split("/");return t&&t.length&&t[t.length-1]},getGraphQLProduct:async function(e){return new Promise(((t,o)=>{let i=window&&window.Shopify&&window.Shopify.locale,r=window&&window.Shopify&&window.Shopify.country;if(i){let o=`query productDetails @inContext(country: ${r}, language: ${i.toLocaleUpperCase().replace("-","_")}) {\n productByHandle(handle: "${e}") {\n handle\n }\n }`;var d=new XMLHttpRequest;d.open("POST",`https://${window.location.hostname}/api/${n.API_VERSION}/graphql.json`,!0),d.setRequestHeader("Content-Type","application/json; charset=UTF-8"),d.setRequestHeader("X-Shopify-Storefront-Access-Token",s.storeFrontAccessToken),d.setRequestHeader("Access-Control-Allow-Origin","*"),d.send(JSON.stringify({query:o})),d.onload=()=>{if(200===d.status){let o=JSON.parse(d.responseText);o&&o.data&&o.data.productByHandle&&o.data.productByHandle.handle?t(o.data.productByHandle.handle):t(e)}else console.log("Error while getting cart")},d.onerror=()=>{console.log("Error while getting cart")}}}))},getProduct:function(e,t=void 0){return new Promise(((o,n)=>{let i=d.getRootRoute();if(!s.storeFrontAccessToken&&!t&&i&&"/"!==i&&s&&s.handleMultiLangProductHandle){let t=d.getProductRequestURL(e);t=t.replace(".js",""),(r=new XMLHttpRequest).open("GET",t,!0),r.setRequestHeader("Content-Type","application/json; charset=UTF-8"),r.send(),r.onload=()=>{if(200===r.status&&r.responseURL!==t){let e=d.getFormattedProductHandle(r.responseURL);d.getProduct(void 0,e).then((e=>{o(e)})).catch((()=>{o(void 0)}))}else d.getProduct(e,e).then((e=>{o(e)})).catch((()=>{o(void 0)}))}}else if(s.storeFrontAccessToken&&!t&&s&&s.handleMultiLangProductHandle)d.getGraphQLProduct(e).then((e=>{d.getProduct(void 0,e).then((e=>{o(e)})).catch((()=>{o(void 0)}))}));else{let n=d.getProductRequestURL(t||e);var r;(window.lbUpsellComponents&&window.lbUpsellComponents.isServerFetchForced||window&&window.navigator&&window.navigator.userAgent&&window.navigator.userAgent.includes("Mac","iPhone","iPad","iPod"))&&(n=`${n}?t=${(new Date).getTime()}`),(r=new XMLHttpRequest).open("GET",n,!0),r.setRequestHeader("Content-Type","application/json; charset=UTF-8"),r.send(),r.onload=()=>{200===r.status?o(JSON.parse(r.responseText)):(404===r.status&&d.debugLog(`${e}, product is out of stock.`),o(void 0))}}}))},getProducts:function(e){return new Promise(((t,o)=>{let n=[];e.forEach((e=>{n.push(d.getProduct(e))})),Promise.all(n).then((e=>{e&&e.length&&(e=e.filter((e=>e))),t(e)}))}))},isImgAvailable:function(e){return e&&e.featured_image||e&&e.media&&e.media.length&&e.media[0].src},getCart:function(e){return new Promise(((t,o)=>{var n=new XMLHttpRequest;n.open("GET",`https://${e}/cart.js`,!0),n.setRequestHeader("Content-Type","application/json; charset=UTF-8"),n.setRequestHeader("Access-Control-Allow-Origin","*"),n.send(),n.onload=()=>{200===n.status?t(JSON.parse(n.responseText)):o("Error while getting cart")},n.onerror=()=>{o("Error while getting cart")}}))},getWidgetSetup:function(e,t){return e&&e.widgets&&e.widgets.length?e.widgets.find((e=>e.type===t)):void 0},removeExistingStyleTag:function(e){let t=document.getElementById(e);t&&(d.log("Removing existing style tag"),t.remove())},appendCustomTextCssToHead:function(e,t){t&&d.removeExistingStyleTag(t);let o=e,n=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");n.appendChild(i),i.type="text/css",i.id=t,i.styleSheet?i.styleSheet.cssText=o:i.appendChild(document.createTextNode(o))},formatPrice:function(e,t){e/=100;let o=(Math.round(100*e)/100).toFixed(2);return t?Math.round(Number(o||"0")):o},getStyle:function(e,t){var o,n=(e.ownerDocument||document).defaultView;return n&&n.getComputedStyle?(t=t.replace(/([A-Z])/g,"-$1").toLowerCase(),n.getComputedStyle(e,null).getPropertyValue(t)):e.currentStyle?(t=t.replace(/\-(\w)/g,(function(e,t){return t.toUpperCase()})),o=e.currentStyle[t],/^\d+(em|pt|%|ex)?$/i.test(o)?function(t){var o=e.style.left,n=e.runtimeStyle.left;return e.runtimeStyle.left=e.currentStyle.left,e.style.left=t||0,t=e.style.pixelLeft+"px",e.style.left=o,e.runtimeStyle.left=n,t}(o):o):void 0},getRandomSortOrder:function(e){let t=[];for(;t.length{let r=d.getRootRoute(),s=`https://${window.location.hostname}${r||"/"}cart/add.js${o&&window.lbDealeasy?"?src=selleasy":""}`,l=new XMLHttpRequest;l.open("POST",s,!0),l.setRequestHeader("Content-Type","application/json; charset=UTF-8"),l.send(JSON.stringify(e)),l.onload=function(){200===l.status?(n("success"),!t&&window.lbUpsellComponents&&void 0!==window.lbUpsellComponents.validateAndFetchDiscount&&d.getCart(window.location.hostname).then((e=>{window.lbUpsellComponents.validateAndFetchDiscount(e)})).catch((e=>{console.log("Error while fetching cart: discount",e)}))):i(l.status)},l.onerror=e=>{d.log("Error while adding items to cart",e)}}))},updateCart:function(e){return new Promise(((t,o)=>{let n=d.getRootRoute(),i=new XMLHttpRequest;i.open("POST",`https://${window.location.hostname}${n||"/"}cart/update.js`,!0),i.setRequestHeader("Content-Type","application/json; charset=UTF-8"),i.send(JSON.stringify(e)),i.onload=function(){200===i.status?t("success"):o(i.statusText)},i.onerror=e=>{d.log("Error while updateCart cart",e)}}))},arrayUnique:function(e){let t=e.concat();for(let e=0;e=8&&(d.log("Appendin css enhancements 2",s.version),t+=".ppcse-compare-at-price{display:inline!important}.lb-upsell-ppa-carousel{margin-right:5px!important}.lb-upsell-modal-product-details-title{font-size:large!important;padding-top:0!important}.lb-upsell-modal-offer-name{text-align:center!important}.lb-upsell-modal-timer-container{width:96%!important;border-radius:4px!important}.lb-upsell-modal-product-img{border:1px solid #f5f5f5!important}.lb-upsell-modal-product-details-variants select{width:100%!important}.ppcse-tot-container-tot{padding-top:0!important}@media only screen and (max-width:768px){.ppa-add-to-cart-btn,.ppcs-variants-form-select{width:100px!important}}"),e>=15&&(d.log("Appendin css enhancements 3",s.version),t+=".lb-upsell-addon-popup-card .lb-shared-variants-select,.lb-upsell-product-page-card .lb-shared-variants-select,lb-tq-page-upsell .lb-shared-variants-select{width:92px;padding-right:20px!important;background-image:unset!important;min-height:32px;border-color:#d3d3d3!important;outline:0!important;box-shadow:none;margin:0!important}.lb-upsell-product-page-card select{appearance:auto}.lb-upsell-product-page-card .lb-spc-carousel-cont{background-color:#fff;appearance:auto}.lb-upsell-addon-popup-card .lb-spc-details-name,.lb-upsell-addon-popup-card .lb-spc-details-price-cont,.lb-upsell-product-page-card .lb-spc-details-name,.lb-upsell-product-page-card .lb-spc-details-price-cont,lb-tq-page-upsell .lb-spc-details-name,lb-tq-page-upsell .lb-spc-details-price-cont{line-height:21px!important}.lb-prod-prev-price-cont,.lb-upsell-addon-popup-card .lb-spc-details-price-cont,.lb-upsell-product-page-card .lb-spc-details-price-cont,lb-tq-page-upsell .lb-spc-details-price-cont{margin-top:0}.lb-upsell-addon-popup-card .lb-spc-image-cont,.lb-upsell-product-page-card .lb-spc-image-cont,lb-tq-page-upsell .lb-spc-image-cont{margin:9px 0 9px 4px;height:75px;width:75px}.lb-upsell-addon-popup-card .lb-spc-image,.lb-upsell-product-page-card .lb-spc-image,lb-tq-page-upsell .lb-spc-image{height:75px;width:75px;background:#fff}.lb-upsell-addon-popup-card .lb-spc-details-cont,.lb-upsell-product-page-card .lb-spc-details-cont,lb-tq-page-upsell .lb-spc-details-cont{margin:8px}.lb-upsell-addon-popup-card .lb-spc-details-btm,.lb-upsell-product-page-card .lb-spc-details-btm,lb-tq-page-upsell .lb-spc-details-btm{margin-top:6px!important}.lb-upsell-product-page-card .lb-spc-added-var-cont{max-width:358px!important}.lb-upsell-product-page-card .lb-spc-details-btn,.lb-upsell-product-page-card .lb-spc-qty-cont{max-width:86px!important;width:92px;border-color:#d3d3d3!important}.lb-upsell-addon-popup-card .lb-spc-qty-cont,lb-tq-page-upsell .lb-spc-qty-cont{background:#fff;border-color:#d3d3d3!important}.lb-upsell-modal-product-details-title{font-size:18px;line-height:27px;font-weight:400;padding:4px 0 2px}.lb-tpae-upsell{max-width:400px}.lb-prod-prev-price-cont b{font-weight:400}.lb-prod-prev-img-wrap{border:none}.lb-prod-prev-img-index{margin:6px}.lb-prod-preview-desc{overflow-y:overlay}.lb-prod-prev-title{line-height:30px}.lb-prod-prev-price-cont{line-height:16px}.lb-upsell-modal-product-details-quantity{margin:16px 0}.lb-upsell-modal-product-details-variants{padding-top:8px}.lb-upsell-modal-product-details-variants .lb-shared-variants-select{width:100%;border-radius:8px;border-color:#d3d3d3!important}.stepper-container-input,.stepper-container-minus,.stepper-container-plus{border-color:#d3d3d3!important}.lb-prod-prev-variants-cont .lb-shared-variants-select{border-color:#d3d3d3!important;outline:0!important;box-shadow:none!important}.lb-upsell-ppa-card-cont{margin-bottom:var(--lb-upsell-ppa-margin-bottom,20px)}.lb-upsell-ppa-title-cont{margin-top:16px!important}.lb-spc-check-cont-bundle{width:16px;height:16px;border:1px solid var(--lb-spc-cta-bg)}.lb-spc-check-cont-class{background:#fff!important;border:1px solid #d3d3d3}.lb-spc-check-cont-disabled{pointer-events:none;opacity:.5}@media (max-width:480px){.lb-addon-popup-title,.lb-upsell-modal-title{font-size:16px}.lb-addon-popup-subtitle,.lb-upsell-modal-timer-container-new{font-size:14px}.lb-upsell-modal-product-img-cont{margin-right:0!important}.lb-upsell-modal-product-img{height:200px!important}.lb-upsell-modal-nav{top:-126.5px!important}lb-upsell-addon-popup .lb-spc-cont{width:100%!important}lb-upsell-addon-popup .lb-spc-details-variants .lb-shared-variants-select{width:92px!important;padding-right:25px!important}.lb-prod-prev-body-cont-height{min-height:50vh!important;max-height:54vh!important}.lb-upsell-modal-body{max-height:calc(60vh - 160px)}.lb-addon-popup-container{max-height:60vh!important}.lb-addon-popup-body{max-height:calc(60vh - 134px)!important}.lb-addon-popup-body-max-height{max-height:calc(60vh - var(--lb-addon-popup-body-max-height))!important}}@media (min-width:961px){.lb-addon-popup-container{max-height:82vh!important}.lb-addon-popup-body{max-height:calc(82vh - 134px)!important}.lb-addon-popup-body-max-height{max-height:calc(82vh - var(--lb-addon-popup-body-max-height))!important}.lb-upsell-modal-body{max-height:calc(82vh - 160px)}.lb-prod-prev-body-cont-height{max-height:70vh!important}}@media (min-width:1025px){.lb-addon-popup-container{max-height:77vh!important}.lb-addon-popup-body{max-height:calc(77vh - 134px)!important}.lb-addon-popup-body-max-height{max-height:calc(77vh - var(--lb-addon-popup-body-max-height))!important}.lb-upsell-modal-body{max-height:calc(77vh - 160px)}}"),t},isCartPage:function(){return-1!==window.location.pathname.indexOf("/cart")},getSampleSnippetSetup:function(){return{isEnabled:!0,isSubscribed:!0,shopCurrencyCode:"INR",version:15,shopCurrencyFormat:"Rs. ",shopEmailCurrencyFormat:"Rs. ",isAmountNoDecimals:!1,accountMetricId:"f6b96261-76f2-4498-a3ad-550d3510c839",widgets:[{content:{totalLabel:"Total price",addToCartSuccessMsg:"Added to your cart!",thisItemLabel:"",title:"Frequently Bought Together",buttonLabel:"Add to cart"},createdAt:1626088296638,myShopifyDomain:"lb-upsell-demo.myshopify.com",isEnabled:!0,styles:{mobile:{imageHeight:"75px",widgetMargin:"20px 0px 20px 0px "},desktop:{imageHeight:"100px",widgetMargin:"40px 0px 40px 0px "}},position:{mobile:{insertPosition:"afterend",selector:".product-form"},desktop:{insertPosition:"afterend",selector:".product-form"}},useShopifyProductRecommendations:!0,maxItemsInOffer:2,recordType:"widget#ppcse",widgetMetricId:"fd647d99-6991-4970-a2d6-cebf0890807a",type:"product-page-cross-sell-embedded-widget",addToCartAction:"redirect",recommendationDiscount:{isEnabled:!0,type:"percentage",value:10,description:"Get {{discount}} off on bundle!"}},{content:{addToCartSuccessMsg:"Added to cart",removeBtnLabel:"Remove",title:"Select addons",addToCartBtnLabel:"Add to cart",addedToCartBtnLabel:"Added"},myShopifyDomain:"hp-dev-1.myshopify.com",isEnabled:!0,position:{mobile:{insertPosition:"beforebegin",selector:"addToCartBtn"},desktop:{insertPosition:"beforebegin",selector:"addToCartBtn"}},layoutStyle:"card-list",addActionStyle:"checkbox",productClickActionStyle:"popup",useShopifyProductRecommendations:!0,recordType:"widget#ppa",type:"product-page-addon-widget",widgetMetricId:"e28a6f2f-547a-4201-b151-0643caf4e32a",addToCartAction:"trigger",recommendationDiscount:{isEnabled:!0,type:"percentage",value:10}},{content:{totalLabel:"Total",countDownTimerText:"Limited time offer! Expires in {{timer}}",continueBtnLabel:"Continue",countDownTimerMins:5,countDownTimerSecs:0,addToCartBtnLabel:"Add",widgetDiscountLabel:"Limited time offer! Expires in {{timer}}",widgetTitle:"You might also like these"},createdAt:1659774736998,myShopifyDomain:"hp-dev-2.myshopify.com",isMultipleVariantsAdded:!0,isEnabled:!0,recordType:"widget#cppa",widgetMetricId:"18e31faf-0a17-4e57-aa4f-f5fbd587401f",type:"popup-cart-addons-widget"}]}}}}},__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var o=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e](o,o.exports,__webpack_require__),o.exports}(function(window){const ppcseWidget=__webpack_require__(907),ppaWidget=__webpack_require__(1),pufWidget=__webpack_require__(873),tpaeWidget=__webpack_require__(818),cartPageUtils=__webpack_require__(44),cartUpdate=__webpack_require__(655),metrics=__webpack_require__(895),utils=__webpack_require__(839),discounts=__webpack_require__(570),checkoutHandler=__webpack_require__(582),addToCartHandler=__webpack_require__(884),setupHandler=__webpack_require__(931);let HOST_NAME=utils.getHostName(),setup,cart,callbackResults={isWidgetScriptLoaded:!1,isSetupLoaded:!1,isCartLoaded:!1};function processPufWidget(){let e=utils.getWidgetSetup(setup,"popup-upsell-funnel-widget");if(e&&e.isEnabled){let t=document.createElement("lb-upsell-modal");if(document.body.append(t),e.isPreRenderingEnabled){let e,t=utils.getWidgetSetup(setup,"product-page-cross-sell-embedded-widget"),o=discounts.getDiscountFromStorage();t&&t.isEnabled&&o&&o.code&&(e=o.code.includes("BUNDLL")&&discounts.isDiscountValid(cart,o)),pufWidget.pufWidgetLib().initiateOffer(setup,cart,!e,!1)}}}function processPcaWidget(){let e=utils.getWidgetSetup(setup,"popup-cart-addons-widget");if(e&&e.isEnabled){let e=document.createElement("lb-upsell-addon-popup");document.body.append(e)}}function renderWidgets(){window.lbUpsellComponents&&(window.lbUpsellComponents.isEnabled=setup&&setup.isEnabled),setup&&setup.isEnabled?(discounts.process(setup,cart),ppcseWidget.ppcseWidgetLib().render(setup,cart),ppaWidget.ppaWidgetLib().render(cart),tpaeWidget.TpaeWidgetLib().render(setup),checkoutHandler.registerListeners(setup),!setup||setup.version>=18||addToCartHandler.registerListeners(),window.location.pathname.includes("/orders/")||window.location.pathname.includes("/checkouts/")?utils.log("Cart page widgets will not be loaded in TQ page"):setup&&setup.version<15&&(processPufWidget(),processPcaWidget()),executeCustomJs(),registerMutationObserver(),registerCartChangeListeners(),setup.version>=18&&cartUpdate.addCartUpdateListener(),discounts.validateStackDiscount(setup,cart),discounts.validateAndFetchDiscount(cart),utils.isCartPage()&&setup.version>=13&&cartPageUtils.prerenderCartOffer()):utils.log("App Not enabled in admin")}function registerCartChangeListeners(){if(window.lbUpsellComponents&&!window.lbUpsellComponents.isFetchIgnored){const e=["/cart/update","/cart/change"],t=window.XMLHttpRequest.prototype.open;window.XMLHttpRequest.prototype.open=function(){return this.addEventListener("load",(function(){if(this._url&&e.some((e=>this._url.includes(e)))){utils.log("XML listener URL",this._url);try{JSON.parse(this.responseText)&&discounts.handleDiscountAfterClick()}catch(e){utils.log("Error on network listener")}}})),t.apply(this,arguments)};const{fetch:o}=window;window.fetch=async(...t)=>{let[n,i]=t,r=await o(n,i);return r&&"function"==typeof r.clone&&r.clone().json().then((function(t){n&&e.some((e=>n.includes(e)))&&discounts.handleDiscountAfterClick()})).catch((e=>{})),r}}if(setup&&setup.version>=13&&utils.isCartPage()){utils.log("Registerred registerCartChangeListeners");const e=["/cart/add","/cart/update","/cart/change","/cart/clear"],t=window.XMLHttpRequest.prototype.open;window.XMLHttpRequest.prototype.open=function(){return this.addEventListener("load",(function(){e.some((e=>this._url&&this._url.includes(e)))&&(utils.log("XML listener URL",this._url),localStorage.removeItem("lb-upsell-cart-prerendered-data"),utils.triggerCustomEvent({url:this._url},"lb-upsell-cart-updated"))})),t.apply(this,arguments)},function(t,o){"function"==typeof o&&(utils.log("Running ns fetch"),t.fetch=function(){var t=o.apply(this,arguments);return t.then((t=>{t&&t.url&&e.some((e=>t.url.includes(e)))&&(utils.log("Fetch listener URL",t.url),utils.triggerCustomEvent({url:t.url},"lb-upsell-cart-updated"))})),t})}(window,window.fetch),window.addEventListener("lb-upsell-cart-updated",(function(e){utils.log("lb-upsell-cart-updated event:",e),localStorage.removeItem("lb-upsell-cart-prerendered-data"),cartPageUtils.prerenderCartOffer()}))}}function registerMutationObserver(){if(setup.version>=10){const e=new MutationObserver((e=>{e&&e.length&&e.forEach((e=>{if(e.addedNodes&&e.addedNodes.length)for(let t of e.addedNodes)if(t&&t.querySelectorAll)if(setup.checkoutBtnSelector)window.lbUpsellComponents.registerCheckoutListeners(!0,t);else{let e=t.querySelectorAll("button[type='submit'][name='checkout'], input[type='submit'][name='checkout'], a[href='/checkout']");e.length&&(utils.log("mutationObserver checkoutNodes",e),void 0!==window.lbUpsellComponents&&window.lbUpsellComponents.registerCheckoutListeners(),setup.customDiscountHelpPosition&&setup.customDiscountHelpSelector&&(utils.log("Calling discounts.process as customDiscountHelpPosition is set"),utils.getCart(window.location.hostname).then((e=>{discounts.process(setup,e)}))))}}))})),t=document.querySelector("body");e.observe(t,{childList:!0,subtree:!0})}}function executeCustomJs(){setup&&setup.isEnabled&&setup.customJs&&setup.customJs.length&&(utils.log("Running custom Js"),eval(setup.customJs))}function appendFloatingToastToBody(){if(window.location.pathname.includes("/cart")){let e=document.querySelector("ppcse-floting-toast");e&&e.remove();const t=document.createElement("ppcse-floting-toast");document.body.append(t)}}function appendProductDetailsModalToBody(){let e=utils.getWidgetSetup(setup,"product-page-cross-sell-embedded-widget"),t=utils.getWidgetSetup(setup,"product-page-addon-widget");if(!utils.isCartPage()&&setup&&setup.version<15&&(e&&e.isEnabled||t&&t.isEnabled)){utils.removeExistingWidget("ppcse-modal");const e=document.createElement("ppcse-modal");document.body.append(e)}if(setup&&setup.version>=15&&setup.offers&&setup.offers.length&&!utils.isCartPage()&&setup.offers.some((e=>"frequently-bought-bundle"===e.upsellType||"product-addons"===e.upsellType))&&(e&&e.isEnabled||t&&t.isEnabled)){utils.removeExistingWidget("lb-upsell-product-preview");const e=document.createElement("lb-upsell-product-preview");document.body.append(e)}}function callbackHandler(e,t){"widget"===e?callbackResults.isWidgetScriptLoaded=!0:"setup"===e?(setup=t||setup,callbackResults.isSetupLoaded=!0):"cart"===e&&(callbackResults.isCartLoaded=!0),callbackResults.isSetupLoaded&&(utils.setSetup(setup),setup.version>=6&&(utils.log("Appendin css enhancements",setup.version),utils.appendCustomTextCssToHead(utils.getCSSEnhancements(setup.version),"lb-upsell-enhancements-css"))),callbackResults.isSetupLoaded&&setup&&setup.isEnabled&&setup.diyCss&&setup.diyCss.formattedCss&&setup.diyCss.formattedCss.length&&utils.appendCustomTextCssToHead(`${setup.diyCss.formattedCss}`,"lb-upsell-diy-css"),callbackResults.isSetupLoaded&&setup&&setup.isEnabled&&setup.customCSS&&setup.customCSS.length&&utils.appendCustomTextCssToHead(setup.customCSS,"lb-upsell-custom-css"),callbackResults.isWidgetScriptLoaded&&callbackResults.isSetupLoaded&&setup&&setup.isEnabled&&appendFloatingToastToBody(),callbackResults.isSetupLoaded&&setup&&setup.isEnabled&&callbackResults.isWidgetScriptLoaded&&appendProductDetailsModalToBody(),callbackResults.isWidgetScriptLoaded&&callbackResults.isSetupLoaded&&callbackResults.isCartLoaded&&("complete"===document.readyState||"interactive"===document.readyState?renderWidgets():document.addEventListener("DOMContentLoaded",(function(){renderWidgets()})))}function initWidgets(){if(0===getScriptCount(scripts,!0)){var e=`${HOST_NAME}/lb-upsell-components/lb-upsell-components.esm.js`,t=document.createElement("script");t.defer=!0,t.readyState?t.onreadystatechange=function(){"loaded"!=t.readyState&&"complete"!=t.readyState||(utils.log("Widget script loaded successfully."),t.onreadystatechange=null,callbackHandler("widget"))}:t.onload=function(){utils.log("Widget script loaded successfully."),callbackHandler("widget")},t.src=e,t.type="module",document.getElementsByTagName("head")[0].appendChild(t)}else utils.log("componentScriptCount !== 0."),callbackHandler("widget")}function getScriptSrc(e){let t;for(let o=0;o{cart=e,cart&&cart.item_count&&cart.item_count>0&&discounts.validateAndFetchDiscount(cart),callbackHandler("cart")})).catch((e=>{utils.log("err while fetching cart:",e)}))}void 0===window.lbUpsellComponents&&(window.lbUpsellComponents={ppcseWidget:ppcseWidget.ppcseWidgetLib(),pufWidget:pufWidget.pufWidgetLib(),ppaWidget:ppaWidget.ppaWidgetLib(),tpaeWidget:tpaeWidget.TpaeWidgetLib(),registerCheckoutListeners:checkoutHandler.registerListeners,registerAddToCartListeners:addToCartHandler.registerListeners,handleUpsellFunnelCheckout:void 0,validateAndFetchDiscount:discounts.validateAndFetchDiscount,renderSelleasyCheckoutPopup:checkoutHandler.renderSelleasyCheckoutPopup});let scripts=document.getElementsByTagName("script"),IS_SNIPPET_TESTING=utils.isSnippetTesting();if(IS_SNIPPET_TESTING)console.log("Testing mode is enabled. Metrics will not work."),initWidgets(),setup=utils.getSampleSnippetSetup(),callbackResults.isCartLoaded=!0,callbackHandler("setup");else if("complete"===document.readyState&&getScriptCount(scripts)>1)utils.log("Script registered in head and scriptTag, so skipped running the script from scriptTag");else{const e=getScriptSrc(scripts);let t=utils.getURLParam("shop",e);if(t&&t.includes(" ")&&(t=t.replace(/\s/g,"")),window.location.pathname.includes("/orders/")||window.location.pathname.includes("/checkouts/")){const e=localStorage.getItem("lbUpselPixel");e?localStorage.removeItem("lbUpselPixel"):metrics.trackConversion()}const o="true"===utils.getURLParam("isNotRenderedInHome",e)&&"/"===window.location.pathname;o||window.lbUpsell&&(!window.lbUpsell||window.lbUpsell.isInitialized)?utils.log("Not initalising assests - isNotRenderedInHome - ",o):t?initAssets(t):utils.log("myShopifyDomain not found")}})(window)})();